Amazon SNS [Simple Notification Service] Using CLI

Опубликовано: 16 Июль 2026
на канале: Web Technology Funda
4,505
18

SNS [Amazon Simple Notification Service]:

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.

There are severals components of AWS SNS as follows:

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 [email protected]

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


PHP Web Technology Funda | AWS Cloud

Read my blog here : https://www.howtoinmagento.com/

Tips & Tricks of PHP Frameworks & AWS Cloud Computing