Manage Triggers for an AWS CodeCommit Repository

You can configure a CodeCommit repository so that code pushes or other events trigger
actions,
such as sending a notification from Amazon Simple Notification Service (Amazon SNS)
or invoking a function in AWS Lambda. You
can create up to 10 triggers for each CodeCommit repository.

Triggers are commonly configured to:

Send emails to subscribed users every time someone pushes to the repository.

Notify an external build system to start a build after someone pushes to the main
branch
of the repository.

Scenarios like notifying an external build system require writing a
Lambda function to interact with other applications. The email scenario simply requires
creating
an Amazon SNS topic.

This topic shows you how to set permissions that allow CodeCommit to trigger actions
in
Amazon SNS and Lambda. It also includes links to examples for creating, editing,
testing, and deleting triggers.

Create the Resource and Add Permissions for CodeCommit

You can integrate Amazon SNS topics and Lambda functions with triggers
in CodeCommit, but you must first create and then configure resources with a policy
that allows
CodeCommit the permissions to interact with those resources. You must create the resource
in the
same region as the CodeCommit repository. For example, if the repository is in US
East (Ohio)
(us-east-2), the Amazon SNS topic or Lambda function must be in
US East (Ohio).

For Amazon SNS topics, you do not need to configure additional IAM policies or
permissions if the Amazon SNS topic is created using the same account as the CodeCommit
repository.
You can create the CodeCommit trigger as soon as you have created and subscribed to
the Amazon SNS
topic.