AWS CodeCommit - Set up Notifications
Inception: Learn, how to send Notification based on events in CodeCommit repository.
In general, you would like to set up a Notification system that should be subscribable. These notification must be triggered based on some events that are configured.
You may want to Notify a group of engineers when a commit happens, or a Pull Request got created, or Source merged, or a new Branch got created, etc.
There are the following events that can trigger notifications.
Comments
- On commits
- On pull requests
Approvals
- Status changed
- Rule override
- Pull request
Source updated
- Created
- Status changed
- Merged
Branches and tags
- Created
- Deleted
- Updated
You can create one or multiple targets for same events. Like you can push Notification to a SNS topic, and at the same time you can send notification to a AWS Chatbot (Slack) channel as well.
Create a Notification Rule
Following are the steps to create a Notification rule in AWS CodeCommit repository.
- Sign in to the AWS Management Console and open the CodeCommit repository at https://us-west-2.console.aws.amazon.com/codesuite/codecommit/repositories
- Click on the repository for which you want to set up Notification.
- Click on the Settings link in the left side options.
- You can see the setting of the repository.
- Click on the Notifications tab
- Click on the Create Notification rule button to create a new Notification.
- Enter the Notification Name
- Select Detail type, you want to send in Notification.
- Select one or more Events that trigger notifications
- Finally create a target to send a Notification to it.
- Submit the Notification creation.
Subscribe the Notifications
Developers and leads can subscribe to the SNS (Simple Notification Service) notification so that on event triggers they will get notified.
The following are the steps to subscribe to the notification.
- Sign in to the AWS Management Console and open the CodeCommit repository at https://us-west-2.console.aws.amazon.com/codesuite/codecommit/repositories
- Click on the repository of which you want to subscribe the notification.
- Click on the Settings link in the left side options.
- Click on Notifications tab.
- Click on the notification rule you have created.
- You will get Notification rule targets, if you have already configured the Notifications.
- Click on the SNS’s Address or endpoint. It will navigate to Topics list of Amazon SNS console.
- Click on the Topic.
- You will see Create subscription button. Click on it.
- There are multiple Protocol, that you can subscribe.
- Lets make it simple and select Email, and Enter your valid email address in Endpoint text field.
- Click on Create subscription button.
- It will create a Subscription, and Status will show as
Pending confirmation
. - Login to your email, you will receive an email with subject
AWS Notification - Subscription Confirmation
. - Click on
Confirm subscription
link to confirm the subscription. - You must see Subscription confirmed! message.
- On Subscription console, you will see status as
Confirmed
. - Now any configured action will trigger a notification to SNS topic and the same will be received by all subscribers.
Conclusion: Now, you can set up a Notification based on different events occurance in CodeCommit repository. These Notification can be targeted to SNS topic and AWS Chatbot(Slack) both.