The CodeCommit Lambda event source allows you to trigger lambda functions in response to CodeCommit repository events.
Lambda functions triggered in response to CodeCommit evetms use a combination of events and branches to manage which state changes trigger your lambda function.
To create an event subscriber use a constructor as in:
// CodeCommit reactor function
func reactorFunc(ctx context.Context, event awsLambdaEvents.CodeCommitEvent) (interface{}, error) {
logger, _ := ctx.Value(sparta.ContextKeyRequestLogger).(*zerolog.Logger)
logger.Info().
Interface("Event", event).
Msg("Event received")
return &event, nil
}
func main() {
// ...
handler := spartaArchetype.NewCodeCommitReactor(reactorFunc)
reactor, reactorErr := spartaArchetype.NewCodeCommitReactor(handler,
gocf.String("MyRepositoryName"),
nil, // Defaults to 'all' branches
nil, // Defaults to 'all' events
nil) // Additional IAM privileges
...
}