AWS CodeCommits based SNS Topic Notification in Emails

How do we enable simple email notification of code commits when made in AWS? This is my topic to explore in AWS infra setup this week.

Objective

To enable simple email notifications for code commits in AWS, you can integrate AWS CodeCommit with Amazon SNS (Simple Notification Service) and EventBridge. This setup will send notifications via email whenever a commit is made in a CodeCommit repository. The process involves creating an SNS topic, setting up a subscription to the topic (via email), creating an EventBridge rule to capture CodeCommit events, and linking these components together. Below are the detailed technical steps for setting up this notification system:

First, navigate to the SNS dashboard in the AWS Management Console. Create a new SNS topic by selecting "Create topic." Choose a standard topic type, provide a topic name, and optionally enter a display name. After creating the topic, you will be directed to the topic details page. Here, you will find the Topic ARN (Amazon Resource Name), which will be used to associate the topic with your CodeCommit events.

Next, you will need to subscribe to the SNS topic. To do this, select the Create subscription button from the SNS topic details page. For the protocol, choose Email and then enter the email address where you want to receive notifications. After you add the email, an email verification message will be sent to the specified address. You must open the email and click the confirmation link to complete the subscription process.

After confirming your email, proceed to AWS CodeCommit. If you don’t already have a CodeCommit repository, create one by navigating to the CodeCommit dashboard and selecting Create repository. Provide a repository name and description, then click Create.

Now, you need to set up an EventBridge rule to capture the CodeCommit commit events. Go to the EventBridge service in the AWS Console. Select Create rule and provide a name for your rule, such as "CodeCommitCommitNotification." In the Event pattern section, choose AWS services and then select CodeCommit from the service name dropdown. Under the Event type, select CodeCommit Repository State Change, and choose Commit Created as the event pattern.

Once the event pattern is set, under the Select targets section, click Add target and choose SNS topic as the target type. In the SNS topic ARN field, paste the ARN of the SNS topic you created earlier. This associates the EventBridge rule with the SNS topic. Optionally, you can configure the rule to trigger for specific repositories if needed.

Finally, click Create rule to finalize the EventBridge setup. Now, whenever a commit is made to the specified CodeCommit repository, the event will trigger the EventBridge rule, which in turn will publish the event to the SNS topic. The SNS topic will send an email notification to the subscribed address.

To test the setup, make a commit to your CodeCommit repository. After the commit, you should receive an email notification containing details about the commit, such as the repository name, the commit ID, and the committer’s information.

By following these steps, you will have successfully set up simple email notifications for code commits made in AWS CodeCommit, using EventBridge and SNS to automate the process.

Let us look at these steps in the sections below:

Creation of CodeCommit



Creation of SNS Topic





Creation of EventBridge Rule






Now make a commit in Code Commit to see the email comes through inbox:

Email arrived on time:


Watch these steps in the video below: Link


Like this article? Subscribe to Engineering Leadership , Digital Accessibility, Digital Payments Hub and Motivation newsletters to enjoy reading useful articles. Press SHARE and REPOST button to help sharing the content with your network.

#LinkedInNewsUK #FinanceLeadership

要查看或添加评论,请登录

NARAYANAN PALANI ???????的更多文章

社区洞察

其他会员也浏览了