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

-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to AWS,
- Create S3 bucket and upload files using AWS Toolkit for Visual Studio Code
- Get the total size and number of objects of a AWS S3 bucket and folders
- Create an S3 bucket in a specific AWS region using CLI Command
- [Solution] AWS Java SDK S3 AmazonS3Exception InvalidAccessKeyId
- Fix AWS CLI 2 SignatureDoesNotMatch Error - Signature we calculated does not match
- 573 List of reserved keywords in AWS DynamoDB
- Quick way to setup AWS DynamoDB locally on macOS
- [Solution] com.amazonaws.dynamodb.v20120810 MissingAuthenticationToken Key Id or X.509 certificate
- Quick way to install AWS CLI for macOS Terminal
- Setting and Updating AWS CLI Configuration
- AWS S3 CLI BucketAlreadyExists when calling CreateBucket Error make_bucket failed
- How to install AWS Toolkit for Visual Studio Code
- Create S3 bucket using AWS CLI Command mb
- Fix: zsh: command not found: aws (Mac/macOS)
- How to install AWS CLI on Ubuntu
- Fix: Amazon Linux bash: sudo: command not found
- How to Setup AWS Credentials using Visual Studio Code
- AW3 CLI command to get list of all region names
- Most Essencial AWS CLI 2 S3 ls Command Options
- Install AWS CLI using Brew Command
More Posts:
- 33: Python Program to find the current time in India (IST) - Python-Programs
- Where are Plugins Installed in Notepad++ - NotepadPlusPlus
- [fix] Chrome: no listeners for an event URLS_SAFE_CHECK__STATUS_UPDATED - Chrome
- Fix [Fatal Error] :2:6: The processing instruction target matching [xX][mM][lL] is not allowed. - Java
- FileZilla Connection time out Failed to retrieve directory listing - FTP
- How to Select All text in vim/vi editor using Keyboard - Linux
- Microsoft Teams Error code - 6 issue - Teams
- Notepad++ select all above or below lines - NotepadPlusPlus