I have a simple Lambda which is configured to be triggered on s3:ObjectCreated:*
event. So when I add an object to s3 bucket my lambda is triggered but lambda handler registered is not invoked.
Code:
package main
import (
"context"
"fmt"
"github.com/aws/aws-lambda-go/lambda"
)
func HandlerS3(ctx context.Context, s3Event events.S3Event) error {
fmt.Println("Handler is called")
fmt.Println("Handler exiting")
return nil
}
func main() {
fmt.Println("Starting Main")
lambda.Start(HandlerS3)
fmt.Println("Ending Main")
}
I get following logs
2024-03-13T16:27:58.889+05:30 INIT_START Runtime Version: provided:al2023.v14 Runtime Version ARN: arn:aws:lambda:us-east-1::runtime:xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2024-03-13T16:27:58.922+05:30 Starting Main
2024-03-13T16:28:08.899+05:30 INIT_REPORT Init Duration: 10009.62 ms Phase: init Status: timeout
2024-03-13T16:28:08.954+05:30 Starting Main
2024-03-13T16:28:14.921+05:30 INIT_REPORT Init Duration: 6006.23 ms Phase: invoke Status: timeout
It looks like there's an issue with initialization or perhaps a missing component or misconfiguration causing the handler not to trigger. Has anyone encountered a similar situation or can offer insights into why HandlerS3
isn't being invoked as expected?
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?