Ends in
00
days
00
hrs
00
mins
00
secs
ENROLL NOW

Get $4 OFF in AWS Solutions Architect & Data Engineer Associate Practice Exams for $10.99 ONLY!

AWS CodeCommit Repository

AWS CodeCommit Repository

Last updated on June 5, 2023

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.

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

Tutorials dojo strip

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

Get $4 OFF in AWS Solutions Architect & Data Engineer Associate Practice Exams for $10.99 ONLY!

Tutorials Dojo portal

Be Inspired and Mentored with Cloud Career Journeys!

Tutorials Dojo portal

Enroll Now – Our Azure Certification Exam Reviewers

azure reviewers tutorials dojo

Enroll Now – Our Google Cloud Certification Exam Reviewers

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS Exam Readiness Digital Courses

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

FREE Intro to Cloud Computing for Beginners

FREE AWS, Azure, GCP Practice Test Samplers

Recent Posts

Written by: Matt Hidalgo

Matt is a Solutions Architect for a managed services provider that specializes in AWS and Azure. After graduating from college with a degree in Geology, he decided to switch careers and self-taught himself with AWS and Azure. Matt specializes in the migration and deployment of workloads to AWS and Azure with 3 years of experience.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?