Amazon SNS [Simple Notification Service] Using CLI
SNS [Amazon Simple Notification Service]:
SNS means Simple Notification Service. It provides robust messaging service for web applications.
It is a versatile messaging service which can deliver message to any devices also to send notification to different AWS resources.
SNS offers 'push' messaging service which is based on publisher subscriber model that means multiple publishing application can to communicate with multiple subscribing application using AWS SNS.
It supports multiple transport protocols that are Amazon SQS, Lambda, HTTP, HTTPS, Email, SMS and Mobile Notifications.
Following are the components of AWS SNS:
Topic:
It contains subject and content event each topic has unique identifier [ URI ]. URI identify the SNS endpoint to publishing and subscribing for messages related to particular topic.
Owners:
They are the topic creators which defines the topics
Subscribers:
They are the belongs the client, end users, applications, services that wants to receives notification on specific topic. Single topic can have multiple subscribers.
Publishers:
They are the message or notification carriers they send message to topics and SNS matches the topic with list of subscribers interested in that topic and deliver message to each one. Publisher have rights to publish message on different topics
Lets see...
How To Configure SNS Using AWS CLI:
First create a SNS topic using command below:
>> aws sns create-topic --name pg-topic
Output:
"TopicArn": "arn:aws:sns:us-east-2:948488888:pg-topic"
Save this ARN for future reference or usage.
Now subscribe to this pg-topic topic:
>> aws sns subscribe --topic-arn EnterTopicARN --protocol email --notification-endpoint pranaydac08@gmail.com
Once we execute above command it will send confirmation email on that email ID and they need to confirm subscription by clicking on confirmation link then only publisher can send emails to subscriber.
Now publish topic and send email to subscriber:
>> aws sns publish --topic-arn EnterTopicARN --message "This is test message..."
This will send email to all subscribers who subscribed this "pg-topic" topic and you can also confirm this from AWS management console by clicking on menu SNS.
How To Unsubscribe Topic Using CLI:
>> aws sns unsubscribe --subscription-arn EnterSubscriptionARN
How To Delete AWS SNS Topic Using CLI:
>> aws sns delete-topic --topic-arn EnterTopicARN
We can get topic ARN by using command below:
>> aws sns list-topics
Please note in next session we will learn "How To Configure SQS Using AWS CLI"...
Happy Learning AWS Services!!!! :) Still Doubts? lets put your questions in below comment box! Thanks!
Watch Video:
Amazon SNS [Simple Notification Service] Using CLI
Reviewed by Web Technology Funda
on
10:21:00 AM
Rating:
No comments