Use Case: Subscription confirmation
Receiving confirmation to a subscription
- 1 Receiving confirmation to a subscription
- 1.1 Problem
- 1.2 Solution
- 1.2.1 Create a topic
- 1.2.2 Subscribe to a topic
- 1.2.3 Check the endpoint for the confirmation
- 1.2.4 Filter the messages in the Email
- 1.2.5 Filter out the latest message received from AWS
- 1.2.6 Parse the Subscription Arn in text format to JSON format
- 1.2.7 Select the Subscription Token
- 1.2.8 Confirm the subscription
- 1.2.9 Delete the subscription
- 1.2.10 Delete the topic
- 1.3 Downloads
If you want to subscribe to any endpoint such as a website or an email to receive messages, the Subscription Arn is unique and different for each user.
Problem
Every time a new user wants to subscribe an endpoint, the AWS SNS generates a new Subscription Arn which needs to be retrieved from the endpoint and used to confirm the subscription. This process in real-time can be resource-intensive and time-consuming if done manually. There is always the chance of a human error in a manual process. Besides, Subscription Arn is in text format which needs to be converted to JSON for an error-free retrieval.
Solution
Using AWS SNS Snap Pack, you can receive a subscription by having a valid topic and an endpoint. Once we have a valid endpoint, Subscribe Topic is used to subscribe an endpoint to a topic. Subscription confirmation is received when a topic is subscribed and the subscription is approved by an endpoint. Once approved, you will receive a Subscription Arn. Here, to confirm the subscription, Email Reader, Filter and Head Snaps are used to filter out the latest Email from the messages received and retrieve the latest topic Arn.
Understanding the Solution
Key Steps
Create a topic
The Create Topic Snap is configured with the following attributes and tag attributes. The Snap Settings and output view of the Snap are displayed as follows:
Subscribe to a topic
An endpoint is subscribed to a topic. Here we are using the email-JSON protocol and giving the email ID as an endpoint. The Snap Settings and output view of the Snap are displayed as follows:
Check the endpoint for the confirmation
The Email Reader Snap is used to read the email. The email from the AWS SNS is filtered and the latest email is read by the Filter and Head Snaps. The details such as Topic ARN are retrieved from the email. The Snap Settings and output view of the Snap are displayed as follows:
Filter the messages in the Email
Filter out the latest message received from AWS
Parse the Subscription Arn in text format to JSON format
The Mapper Snap is used to parse the Subscription Arn received in the text to JSON. The Snap Settings and output view of the Snap are displayed as follows:
Select the Subscription Token
Confirm the subscription
The subscription is confirmed with the Topic Arn.
Delete the subscription
The Subscribed topic is deleted.
Delete the topic
The created topic can also be deleted by using Delete Topic Snap.
We can use similar Pipelines for different endpoints and subscribe them to a created topic.