CyberKeeda In Social Media

AWS SNS : How to create SNS Topic and add email Subscribers to it.


Amazon Simple Notification Service (SNS) is a highly available, durable, secure, fully managed pub/sub messaging service that enables you to decouple microservices, distributed systems, and serverless applications. 
Additionally, SNS can be used to trigger notification end users using mobile push, SMS, and email.
Source : Official

Within this post, we will cover.

  • How to create SNS Topic and attach Email Subscribers to it via AWS Console.
  • How to create SNS Topic and attach Email Subscribers to it via  AWS CloudFormation script. 

We will start with the use case:

  • If you want to trigger email notifications coupled to any AWS services like AWS lambda function.
  • If you want to fan out AWS lambda function via SNS.


Create SNS Topic using AWS Console.
  • AWS Console -->  SNS --> Create Topic --> Fill detail and Create Topic.
    • Topic Name : Identifier of topic name, could be anything.
    • Display Name : This one is important, when Notification email will land to your email this will be the name for the SNS email, so keep so that it will give you a hint about the notification content.
Once created we will get a Success Notification.

Attach email subscribers to SNS Topic and Verify the Subscription.
  • Under above created SNS topic, scroll down and Click on Create Subscription
  • Fill in the below required details and create Subscriptions.
    • Topic ARN --> Selected by default.
    • Protocol --> Email.
    • Endpoint --> Email address of recipient, if you want notification to your inbox put your email id.
  • Verify Subscription --> You will get a AWS Notification - Subscription Confirmation email.
  • Click on the link to confirm subscription.
  • With respect to filled input within screenshot, something similar you can expect.
  • SNS Topic ARN can be used later to send email notifications or fan out Lambda.
Note : Every time you want to send to notification to new email address, repeat the above process to add Subscriber under same SNS Topic.

Yeah above are the steps to create SNS topic and add subscribers via Console, below is the AWS CloudFormation Script to SNS topic and add email Subscribers to it.

AWS CloudFormation Script.

AWSTemplateFormatVersion: 2010-09-09
DescriptionCFN to create SNS topic and Add two different email Subscribers to it. 
    DescriptionProvide SNS Topic Name
    DescriptionProvide SNS Topic's Display Name, will be used as a name for SNS emails.
    DescriptionProvide DL or email for your SNS Topic.

      TopicName!Sub ${SNSTopicName}
      DisplayName!Sub ${SNSTopicDisplayName}
      - Endpoint!Sub ${SubscriptionEmail}

In case if we want to add more email subscribers, we can append more -Endpoint and Protocol as email to it.

Below one is the hard coded Resource for SNS topic with two email subscribers,  

      DisplayNameSNS Admin

    No comments:

    Post a Comment

    Designed By Jackuna