AWS CodeCommit Repository

Amazon Web Services, with its ever-growing breadth of services, offers a fully-managed version control system where developers can privately store their application source code like Github or Bitbucket. CodeCommit can be used as a staging ground coupled with CodeDeploy and CodePipeline to seamlessly deploy code to Amazon EC2 instances. 

In this article, I will discuss how we can leverage Amazon SNS to send notifications whenever there are events in our repository. This is particularly useful when we need to keep our work colleagues up-to-date if there are events in our repository.

Triggers are used for two things. The first is for notifying users of an event that occurs in our repository by using a simple email notification. Second is by triggering a function to allow us to interact with third-party applications such as Jenkins or other  continuous integration and deployment services.

IT Certification Category (English)728x90

To get started, we need to create an SNS topic (TutorialsDojoTopic) and subscription for the email notification. AWS will send a confirmation email to the subscribed email address.

Create a topic:

Amazon SNS > Topics > Create topic

AWS CodeCommit Repository

In order for Codecommit Notifications to have the necessary permissions to publish emails, you need to modify the Access Policy with the following:

{
  "Version": "2008-10-17",
  "Statement": [
{
   "Sid": "CodeNotification_publish",
   "Effect": "Allow",
   "Principal": {
     "Service": "codestar-notifications.amazonaws.com"
   },
   "Action": "SNS:Publish",
   "Resource": "arn:aws:sns:us-east-1:<ACCOUNT_ID>:<SNS_TOPIC_NAME>"
}
  ]
}

Do not forget to change the account ID and SNS topic name. Remove the < and > characters once done.

AWS CodeCommit Repository
AWS CodeCommit Repository

After creating our SNS topic, we need a subscription. The purpose of the subscription is it specifies what the SNS topic will do when it is triggered to a specified endpoint like Lambda, SQS, or an email address.

Create a subscription, navigate to:

Amazon SNS > Subscriptions > Create Subscriptions

AWS CodeCommit Repository

After you have created an SNS topic and subscription, head over to Codecommit. Here we have already created the TutorialsDojoRepo repository with a file named TutorialsDojo.txt. You can manually create or upload a file to our repository by heading over to the “Add File” section.

AWS CodeCommit Repository

To create our Notifications, go to Settings > Notifications > Create Notifications

AWS CodeCommit Repository

AWS CodeCommit Repository

To determine if the connection between CodeCommit and the SNS topic works, head over to the Notification Rule that you just created then navigate at the bottom. Under Notification Rule Targets, the status must be Active.

Now let us create a scenario wherein a colleague accidentally deletes a branch. To achieve our goal, we must receive an email from AWS stating that a branch has been deleted. 

AWS CodeCommit Repository

 

Sources:
https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-notify.html
https://docs.aws.amazon.com/sns/latest/dg/sns-tutorial-create-topic.html
https://docs.aws.amazon.com/sns/latest/dg/sns-tutorial-create-subscribe-endpoint-to-topic.html

***

AWS Certifications are consistently among the top paying IT certifications in the world, considering that Amazon Web Services is the leading cloud services platform with almost 50% market share! Earn over $150,000 per year with an AWS certification!

Subscribe to our newsletter and notifications for more helpful AWS cheat sheets and study guides like this and answer as many AWS practice exams as you can.🙂

20% OFF Single Item Purchases and BIGGER Bundle Discounts (July 8 to July 13 only)

NEW – AWS Certified Advanced Networking Specialty Practice Exams 2020

AWS Certified Advanced Networking Specialty Practice Exams

NEW – Cloud Practitioner and SA-Associate Exam Study Guide and Cheat Sheets

Tutorials Dojo Study Guide and Cheat Sheets-2

Enroll Now – AWS Certified Cloud Practitioner Practice Exams 2020

AWS Certified Cloud Practitioner New

Enroll Now – AWS Certified Solutions Architect Associate Practice Exams 2020

AWS Certified Solutions Architect Associate Practice Exams New

Enroll Now – AWS Certified Developer Associate Practice Exams 2020

AWS Certified Developer Associate New

Enroll Now – AWS Certified SysOps Administrator Associate Practice Exams 2020

AWS Certified SysOps Administrator Associate New

Enroll Now – AWS Certified Solutions Architect Professional Practice Exams 2020

AWS Certified Solutions Architect Professional New

Enroll Now – AWS Certified DevOps Engineer Professional Practice Exams 2020

AWS Certified DevOps Engineer Professional Practice Exams New

AWS Certified Security Specialty Practice Exams 2020

AWS Certified Security - Specialty Exam Study Path

Browse Other Courses

Generic Category (English)300x250

Recent Posts