Creating an AWS CodeCommit Repository That Triggers Email Notifications

30 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 AWS 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.
    1. Click on Rules in the left-hand menu.
    2. On the CloudWatch Events is now EventBridge page, click Go to Amazon Eventbridge.
    3. Click Create rule.
    4. On the Create rule page, set the following values:
      • Name: codecommitrules
      • Define pattern: Event pattern
      • Event matching pattern: Pre-defined pattern by service
      • Service provider: AWS
      • Service name: CodeCommit
      • Event type: All Events
      • Target: SNS topic
      • Topic: CodeCommitNotify
    5. Click Create.

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.

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 AWS 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?