Menu
AWS CodeCommit
User Guide (API Version 2015-04-13)

Manage Triggers for an AWS CodeCommit Repository

You can configure an AWS 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 ten triggers for each AWS 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.

In this topic, you will learn how to set permissions that allow AWS CodeCommit to trigger actions in Amazon SNS and Lambda. You will also find links to examples for creating, editing, testing, and deleting triggers.

Create the Resource and Add Permissions for AWS CodeCommit

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

  • 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 AWS CodeCommit repository. You can create the AWS CodeCommit trigger as soon as you have created and subscribed to the Amazon SNS topic.

  • If you want to configure your trigger to use an Amazon SNS topic in another AWS account, you must first configure that topic with a policy that allows AWS CodeCommit to publish to that topic. For more information, see Create a Policy That Enables Cross-Account Access to an Amazon Simple Notification Service Topic.

  • Triggers that invoke Lambda functions require more consideration. If you want your trigger to run a Lambda function directly (instead of using an Amazon SNS topic to invoke the Lambda function), you must include a policy to allow AWS CodeCommit to invoke the function. For more information, see Create a Policy for AWS Lambda Integration.