Creating and Subscribing to AWS SNS Topics

15 minutes
  • 3 Learning Objectives

About this Hands-on Lab

In this live AWS environment, you will be using the AWS Simple Notification Service (SNS). You will create an SNS topic and then subscribe to that topic using multiple endpoints (SMS, email, and AWS Lambda). This environment will allow you to demonstrate successful interaction with the SNS service by creating SNS topics and adding subscribers to those topics. At the end of this activity, you will have demonstrated you have a basic understanding of the SNS service, the components within it, and how to use the service in the AWS console.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create an SNS Topic
  • Using the Simple Notification Service (SNS) service, create an SNS topic named "mytopic"
  • Create an email subscription to the SNS topic using your email address
  • Create an SMS subscription to the SNS topic using your phone number
Create a Lambda Function
  • Using the Lambda service, create a Lambda function named "SNSProcessor" using the Python 3.6 runtime and the existing LambdaRoleLA role
  • Using the Simple Notificiation Service (SNS) service, create an AWS Lambda subscription to the SNS topic for the Lambda function
  • Using the Lambda service, update the Lambda function with the following code:
    def lambda_handler(event, context):
        message = event['Records'][0]['Sns']['Message']
        print("From SNS: " + message)
        return message
  • Deploy the Lambda function
Send Your SNS Topic to Multiple Endpoints
  • Using the Simple Notification Service (SNS) service, configure your message content and publish the SNS topic
  • Verify that the SNS topic was successfully sent by confirming that you received the email and text message notifications
  • Using the Lambda service, verify that the SNS topic was successfully sent by confirming that there is an entry for the Lambda function in CloudWatch Logs

Additional Resources

Log in to the AWS Management Console using the credentials provided on the lab instructions page. Please ensure you are using the us-east-1 (N. Virginia region) region.

This lesson's GitHub repo.

NOTE: Currently the sending of SMS may have issues due to AWS origination number requirements. We will be looking into fixes for that functionality in the lab environment. For more information, see: In the meantime, assume the SMS message was sent.

Additionally, please delete your email in the SNS section before closing the lab.

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?