If you want to subscribe to an AWS SNS Topic via the AWS CLI, then you can make use of the aws sns subscribe command.
Let's see step-by-step how to do that.
Step 1: Get the list of all SNS Topics
% aws sns list-topics
-----------------------------------------------------
| ListTopics |
+---------------------------------------------------+
|| Topics ||
|+-------------------------------------------------+|
|| TopicArn ||
|+-------------------------------------------------+|
|| arn:aws:sns:us-east-1:107xx89xx95x:apiTopic ||
|| arn:aws:sns:us-east-1:107xx89xx95x:emailTopic ||
|| arn:aws:sns:us-east-1:107xx89xx95x:smsTopic ||
|+-------------------------------------------------+|
Step 2: Subscribing to a SNS Topic
Example 1: Subscribing an Mobile number to an SNS topic:
% aws sns subscribe
--topic-arn arn:aws:sns:us-east-1:107xx89xx95x:smsTopic
--protocol sms
--notification-endpoint +1-mobile-no
Example 2: Subscribing an Email Address to an SNS topic:
% aws sns subscribe
--topic-arn arn:aws:sns:us-east-1: 107xx89xx95x:emailTopic
--protocol email
--notification-endpoint email@example.com
Example 3: Subscribing an Email Address to an SNS topic:
% aws sns subscribe
--topic-arn arn:aws:sns:us-east-1: 107xx89xx95x:emailTopic
--protocol lambda
--notification-endpoint arn:aws:lambda:us-east-1:107xx89xx95x:function:SNSLambdaInvocationFunc

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!