Skip to main content
Getting started with AWS CodeCommit webhooks

How to set up your CI job or pipeline to utilise webhooks, in order to deploy changes when a branch's contents change

Ali Daw avatar
Written by Ali Daw
Updated this week

This document is a guide to setting up a webhook for CI jobs or Pipelines in Gearset, that deploys changes from an AWS CodeCommit repository whenever the source branch changes.

Before following this guide, you will need to ensure that:

  • you have added a connection to your AWS CodeCommit repository - see this guide for how to connect CodeCommit

  • the AWS CodeCommit repository you are connecting to is not blank and that there is at least one branch (e.g. main) to work with; otherwise, you will get an error when you select the Source repository field on the Add CI deployment job page.

In summary, per CI job or pipeline environment configured to instigate a specific action, you will need the following set up on the AWS side:

  • 1 Simple Notification Service (SNS) Topic

  • 1 Subscription

  • 1 Trigger

  • 1 EventBridge rule

Creating a CI webhook for CodeCommit

  1. To get started, from the Continuous integration page in Gearset, click Add new deployment job or Add new team-shared deployment job.

  2. Select AWS CodeCommit as the Source type.

  3. Under Deployment behaviour, select when the source branch is updated.

Once you’ve configured the other options, click Save and you’ll see another dialog box with the webhook information in it. You’ll then utilise the Payload URL and Shared secret later on to create and configure your CodeCommit webhooks using the guide at the bottom of this document.

Creating a Pipelines webhook for CodeCommit

When configuring a Gearset Pipeline using AWS CodeCommit, you will also be asked to add a specific SNS Topic, Subscription & EventBridge Rule to allow all the Pipeline functionality to work as expected.

  1. Head to the Pipeline page, and click on the settings cog, followed by 'Add webhook...'

  2. This will bring up an informational modal explaining how to add in the SNS Topic, Subscription and EventBridge rule for your pipeline.

    Note that this is over and above the CI job configuration SNS Topics and supporting elements written above, and is unique to setting up a pipeline.

    Once you have noted down your Payload URL and shared secret, proceed with the following steps to add your webhook.

Adding a Webhook

  1. In the AWS Management Console, go to the SNS section (searching for 'Simple Notification Service' at the top)

  2. Create a new topic, then create a new subscription for that topic.

  3. Choose a name for your topic, and set its type as standard

  4. Select HTTPS as the Protocol.

  5. Set the Endpoint to the Payload URL from Gearset’s webhook setup dialog earlier.

  6. The new subscription’s ID will be Pending confirmation.

  7. Click the Request confirmations button and hit the refresh button in the table. The subscription should then be assigned a proper subscription ID.

  8. In the AWS Management Console, go to the AWS CodeCommit section.

  9. For the repository you’re deploying, go to the Settings section, and then to the Triggers tab.

  10. Click the Create new trigger button.

  11. Under Events, select Push to existing branch.

  12. Under Branch names, do not select any branches so that the webhook works for all branches in your pipeline.

  13. Under SNS topic, select the SNS topic you created earlier.

  14. Under Custom data, paste in the Shared secret from Gearset’s webhook setup dialog earlier.

You can test the trigger at this point to check that it can connect successfully.

Now the next time you push to this branch, it will trigger the CI job in Gearset.

Setting up an EventBridge rule

To set up an EventBridge rule, please refer to our guide on EventBridge configuration for the users using AWS CodeCommit

Did this answer your question?