AWS CodeCommit Trigger

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

Create a Trigger in AWS CodeCommit for an Existing AWS Lambda Function

In this step you will create a trigger in CodeCommit which invokes a Lambda function when a branch or tag is created.

  1. Open the CodeCommit console

  2. In Repositories, choose the gitflow-workshop repository where you want to create triggers for repository events.

  3. In the navigation pane for the gitflow-workshop repository, choose Settings, and then choose Triggers. codecommit-lambda-before

  4. Choose Create trigger. In Create trigger, do the following:

  • In Trigger name, enter a name for the trigger (for example, CreateBranch).
  • In Events, choose the repository events that trigger the Lambda function: Create branch or tag.
  • In Branches, leave the selection blank, because this default option applies the trigger to all branches automatically.
  • In Choose the service to use, choose AWS Lambda. In Lambda function, choose the function name from the list, or enter the ARN for the function. codecommit-lambda
  1. Choose Create trigger. In Create trigger, do the following:
  • In Trigger name, enter a name for the trigger (for example, DeleteBranch).
  • In Events, choose the repository events that trigger the Lambda function: Delete branch or tag.
  • In Branches, leave the selection blank, because this default option applies the trigger to all branches automatically.
  • In Choose the service to use, choose AWS Lambda. In Lambda function, choose the function name from the list, or enter the ARN for the function. codecommit-lambda

After you finish those steps , you should see something similar to below: codecommit-lambda-after