
This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.
A Simple Notification Service (SNS) Topic can be used to create notification alerts, such as an email notification. This uses the messaging services pub sub model.
- pub (publish) - create a new alert in a Topic
- sub (subscribe) - get alerts in a Topic
The aws sns list-subscriptions command can be used to the Subscriptions to a Simple Notification Service (SNS) Topic. Likewise, the aws sns list-subscriptions-by-topic command can be used to list the Subscribers of a specific Topic.
aws sns list-subscriptions-by-topic --topic-arn arn:aws:sns:us-east-1:123456789012:my-topic
Notice in this example that john.doe@example.com is PendingConfirmations whereas jane.doe@example.com has an Amazon Resource Number (ARN). This means jane.doe@example.com has confirmed her subscription to the Topic, but john.doe has not. After 3 days, a subscription that is Pending Confirmation will be removed.
{
"Subscriptions": [
{
"SubscriptionArn": "PendingConfirmation",
"Owner": "7112345074123",
"Protocol": "email",
"Endpoint": "john.doe@example.com",
"TopicArn": "arn:aws:sns:us-east-1:123456789012:my-topic"
},
{
"SubscriptionArn": "arn:aws:sns:us-east-1:123456789012:my-topic:e7e1a790-6f3b-432c-ae6d-dae1f1fb5809",
"Owner": "7112345074123",
"Protocol": "email",
"Endpoint": "jane.doe@example.com",
"TopicArn": "arn:aws:sns:us-east-1:123456789012:my-topic"
}
]
}
The aws sns unsubscribe command can be used to unsubscribe a Subscription.
aws sns unsubscribe --subscription-arn arn:aws:sns:us-west-1:123456789012:my-topic:e7e1a790-6f3b-432c-ae6d-dae1f1fb5809
Did you find this article helpful?
If so, consider buying me a coffee over at