Search code examples
amazon-web-servicesgoaws-lambdaaws-codecommit

Go AWS Lambda: Where is event?


Most Lambda runtimes have the following handler signature, which allows accessing both the event and context objects passed into the Lambda:

lambdaHandler(event, context){}

However the documentation for Go Lambda handlers does not follow this convention as shown here: https://docs.aws.amazon.com/lambda/latest/dg/golang-handler.html

Question: How does one access the event object when using the Go Lambda runtime, i.e., when trying to determine the repository URL in an AWS CodeCommit Lambda Trigger (https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-notify-lambda.html)?


Solution

  • Your expected event is of type events.CodeCommitEvent

    func handler(ctx context.Context, codeEvent events.CodeCommitEvent) {
        for _, record := range codeEvent.Records {
            // do you magic here.
        }
    }