Creating an AWS CodeCommit Repository That Triggers Email Notifications

45 minutes
  • 4 Learning Objectives

About this Hands-on Lab

This lab will consist of creating a new AWS CodeCommit repository and adding source control. We will use a trigger in CodeCommit to listen for any new commit to our source code to trigger an email notification via Amazon Simple Notification Service (SNS).

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create a CodeCommit Repository
  1. Open the CodeCommit console.
  2. On the Repositories page, click Create repository.
  3. On the Create Repositories page, set the following values:
    • Repository name: CloudWatchTriggerSNS
    • Description: A test CodeCommit repository
  4. Click Create.
Create an Amazon SNS Topic
  1. Navigate to Amazon SNS.
  2. On the homepage, enter the topic name in the Create Topic section and click Next step.
  3. On the Create topic page, enter the topic name in Display Name to use the topic with SMS subscriptions.
  4. Leave the rest as their defaults and click Create topic.
Subscribe to the Topic
  1. From the Subscriptions page, click Create subscription.
  2. On the Create subscriptions page, set the following values:
    • Protocol: Email
    • Endpoint: Enter your email address
  3. Click Create subscription to send a confirmation message to the registered email.
  4. Open the AWS Subscription Confirmation email and click Confirm subscription.
Create an Event
  1. Navigate to CloudWatch.
  2. Click on Rules in the left-hand menu.
  3. On the CloudWatch Events is now EventBridge page, click Go to Amazon Eventbridge.
  4. Click Create rule.
  5. On the Create rule page, set the following values:
    • Name: codecommitrules
    • Event bus:default
  6. Select Rule with an event pattern
  7. Click Next.
  8. In Event source, select AWS events or EventBridge partner events.
  9. In the Event Pattern section, choose the Event source of AWS Services.
  10. Choose the CodeCommit service.
  11. Choose the event type of All Events.
  12. Click Next.
  13. Choose the Target type of AWS service.
  14. Select a target of SNS topic.
  15. Choose your Topic name.
  16. Click Next.
  17. Click Next.
  18. Click Create rule.

Add an index.html File to the Repository

  1. On the Repositories page, select the newly created repository.
  2. Click Add file > Upload file and select the index.html file from your local computer.
  3. In the Commit changes to master section, set the following values:
    • Author name: Your name
    • Email address: Your email address
    • Commit message: Updated website
  4. Click Commit changes.

Additional Resources

Note: CloudWatch Events is now EventBridge. Please see the lab guide for updated instructions for this lab.

In this lab scenario, our QA team says they are not being properly notified each time there is a code commit to the source code repository. To remedy this, the DevOps team plans to use a trigger in CodeCommit to listen for any new commit to our source code to trigger an email notification via Amazon Simple Notification Service (SNS) to the QA team.

Log in with the credentials provided and make sure you are in the us-east-1 region.

You can find the index.html file used for this lab in the GitHub repository.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?