Reputation: 140
I've an existing lambda function with go1.x runtime, which working fine with sqs triggers. Trying to update the function to use new provided.al2 runtime using the instructions here.
Have updated the binary with bootstrap name, with this updated build command.
GOOS=linux GOARCH=amd64 go build -o bootstrap
After updating this new package and changing runtime, execution is always timing out in the init phase.
INIT_REPORT Init Duration: 10008.47 ms Phase: init Status: timeout
INIT_REPORT Init Duration: 60060.47 ms Phase: invoke Status: error Error Type: Runtime.Unknown
Same code works when I change binary to main and switch back to go1.x runtime. can someone help?
Edit:
Issue is resolved after updating aws-lambda-go library to latest.
Old version is working perfectly fine with Go 1.x runtime. But to use custom amazon linux 2 runtime, had to update the library to latest version.
Upvotes: 4
Views: 4872
Reputation: 81
In case this helps someone, as I was struggling with a similar issue.
I was following the AWS example, and I didn't notice that at some point, they were showing multiple architecture examples amd64 and arm64 https://docs.aws.amazon.com/en_us/lambda/latest/dg/golang-package.html
Anyway, you may notice that there is an optional step. That's kind of related to the architecture type. Well, be aware that the CGO_ENABLED parameter is the integration of C libraries in Go applications. So if you place it as 0 you potentially will block C dependencies to begin use. This will affect you depending on your environment selection and will make your lambda to break, as AWS documentation mentions
This command creates a stable binary package for standard C library (libc) versions, which may be different on Lambda and other devices.
In my case I was using Amazon Linux 2023 arm64 which required the Golang default value 1 (CGO_ENABLED=1) so my command ended like this:
GOARCH=arm64 GOOS=linux go build -o bootstrap main.go
Upvotes: 2
Reputation: 140
Turns out that the github.com/aws/aws-lambda-go library used in existing code is not compatible with new al2 runtime. Have updated this library to the latest version and init timeout error isssue is resolved
Upvotes: 7
Reputation: 53
Could be that you forgot updating the lambda handler setting? See „change the handler“ here: https://www.go-on-aws.com/lambda-go/lambda_function/create-console-custom/
Upvotes: 0