1 Answer
- Newest
- Most votes
- Most comments
0
I added a service ticket in AWS and got a solution
Why Lambda was failing: Lambda functions calls init() of modules and a hard coded timeout of 10ms is kept by AWS. For my function AWS sdk is not able to complete init() in 10ms. Cause: I was using golang on M1 Mac and was compiling for GOOS=linux GOARCH=arm64. Issue was with code compiled with m1 Mac. After compiling same code using Cloud9 or Docker with x68_64 emulated this issue is not seen.
Relevant content
- asked 6 years ago
- asked 5 months ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 9 months ago
Could you Verify that all necessary dependencies are included in your Lambda deployment package. If you're using external libraries or packages, make sure they are properly imported and included in the deployment package
This is how code is compiled and there are no errors
Compiling code for linux/arm64
env GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -tags lambda.norpc -o ./bin/bootstrap ./cmd
Is the Lambda function configured for the arm64 instruction set architecture? See https://docs.aws.amazon.com/lambda/latest/dg/foundation-arch.html#foundation-arch-config
Runtime: Amazon Linux 2023 HandlerInfo: bootstrap ArchitectureInfo: arm64
The only error I got while reproducing this was the following missing import in the code. I was not able to build the binary without it. "github.com/aws/aws-lambda-go/events"
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o bootstrap -tags lambda.norpc main.go
have you checked that?