Guided Lab: Creating an Amazon SNS Email-JSON Subscription
Description
Amazon Simple Notification Service (SNS) is a fully managed messaging service that allows you to send notifications via multiple protocols, including email and email-JSON. The Email-JSON Subscription Protocol in Amazon SNS (Simple Notification Service) allows you to receive notifications in a structured JSON format via email. Unlike the standard Email protocol, which sends a plain-text message, Email-JSON provides a detailed JSON message that includes metadata such as the message attributes, timestamp, and message ID. This format is useful when you need structured data for processing or debugging, as it provides more detail and is easier to parse programmatically. The Email-JSON subscription is often used for systems that need automated handling of notification data.
This lab will guide you through creating an SNS topic and setting up an Email-JSON subscription to receive structured notifications.
Prerequisites
This lab assumes you have the following:
- Basic knowledge and understanding of AWS services, particularly Amazon SNS.
If you find any gaps in your knowledge, consider taking the following lab:
Objectives
By the end of this lab, you will:
- Understand the purpose and benefits of the Email-JSON subscription protocol in Amazon SNS.
- Learn how to create an SNS topic and configure an Email-JSON subscription.
- Verify and test the subscription by sending a notification.
Lab Steps
Create an SNS Topic
1. Navigate to the Amazon SNS Console.
2. To create Topics, look for the Topics in the left-sidebar. Then, click on Create Topic. Follow the configurations below:
- Choose the Standard type.
- Enter a name for the topic, such as
TD-Topic
(as shown in the first image).
- Click Create Topic.
Kindly ignore the “Couldn’t retrieve data protection policy” warning. You can safely finish this lab even without this policy.
Create an Email-JSON Subscription
1. In the Amazon SNS Console, go to Subscriptions in the left sidebar and click Create subscription. Configure the subscription with the following settings:
-
- Topic ARN: Choose the ARN of the
TD-Topic
created earlier. - Protocol: Select Email-JSON.
- Endpoint: Enter the email address where you want to receive the JSON-formatted notification
- Topic ARN: Choose the ARN of the
- Click Create subscription.
Confirm the Email Subscription
1. You will receive an email from AWS SNS to confirm the subscription. Check your inbox for a confirmation link.
2. Click Confirm Subscription.
3. Return to the Subscription you created earlier. The status should have been updated to Confirmed.
Publish a Test Message to the Topic
1. In the SNS Console, go to the Topics section and select TD-Topic
. Then, click on Publish message.
Kindly ignore the “Couldn’t retrieve data protection policy” warning. You can safely finish this lab even without this policy.
- Subject: “Test Notification”
- Message body: “Tutorials Dojo proudly made in the Philippines!”
- Leave the rest as is, scroll down, and click Publish message.
2. Go to the inbox of the email address you used for the subscription.
- Open the email and view the message content. You should see the notification in JSON format, including details like
MessageId
,TopicArn
,Timestamp
, and theMessage
itself.
Congratulations! You have successfully set up an Amazon SNS topic with an Email-JSON subscription and verified that notifications are sent in JSON format. The Email-JSON protocol provides structured data, making it ideal for applications that require detailed message metadata or automated processing.
Key Takeaways:
- Email-JSON subscriptions send notifications in a structured format, offering more details than standard email subscriptions.
- This format is suitable for systems requiring parsing or automated notification handling.
- Amazon SNS provides flexible protocols to meet diverse notification needs.
As a best practice, remember to delete any resources no longer in use, such as SNS topics and subscriptions, to maintain a clutter-free AWS environment.
Thank you for joining this lab, and happy learning!