Home > Article > Backend Development > Lambda custom al2 runtime with golang, initialization phase timeout
I have an existing lambda function with go1.x runtime that works fine with sqs triggers. Try updating the function to use the new provided.al2 runtime as described here.
https://aws.amazon.com/blogs/compute/migration-aws-lambda-functions-from-the-go1-x-runtime-to-the-custom-runtime-on-amazon-linux-2 /
Binaries with the bootstrap name have been updated with this updated build command.
GOOS=linux GOARCH=amd64 go build -o bootstrap
After updating this new package and changing the runtime, the execution always times out during the initialization phase.
INIT_REPORT Initialization duration: 10008.47 ms Phase: init Status: timeout
INIT_REPORT Initialization Duration: 60060.47 ms Phase: Calling Status: Error Error Type: Runtime.Unknown
The same code works when I change the binary to main and switch back to go1.x runtime. Can anyone help?
edit:
The problem has been solved after updating the aws-lambda-go library to the latest version.
The old version runs very well with Go 1.x. But to use a custom Amazon Linux 2 runtime, you must update the libraries to the latest version.
It turns out that the github.com/aws/aws-lambda-go library used in the existing code is not compatible with the new al2 runtime. This library has been updated to the latest version and the initialization timeout error issue has been resolved
The above is the detailed content of Lambda custom al2 runtime with golang, initialization phase timeout. For more information, please follow other related articles on the PHP Chinese website!