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
Before setting up sub (subscribers), you will to create an SNS Topic. Check out my article on Creating a Simple Notification Service (SNS) Topics using the AWS CLI.
~]$ aws sns create-topic --name my-topic
{
"TopicArn": "arn:aws:sns:us-east-1:123456789012:my-topic"
}
The aws sns list-subscriptions-by-topic command can be used to list the Topic Subscribers.
aws sns list-subscriptions-by-topic --topic-arn arn:aws:sns:us-east-1:123456789012:my-topic
If something like this is returned, the Topic currently has no subscribers.
{
"Subscriptions": []
}
On the other hand, if the Topic has one or more subscribers, something like this should be returned. Notice in this example that the SubscrptionArn has PendingConfirmation. Perhaps john.doe@example.com has not yet acknowledged his subscription to the Topic.
{
"Subscriptions": [
{
"SubscriptionArn": "PendingConfirmation",
"Owner": "7112345074123",
"Protocol": "email",
"Endpoint": "john.doe@example.com",
"TopicArn": "arn:aws:sns:us-east-1:123456789012:my-topic"
}
]
}
On the other hand, if the user has confirmed their subscription to the Topic, the Amazon Resource Number (ARN) should be displayed.
{
"Subscriptions": [
{
"SubscriptionArn": "arn:aws:sns:us-east-1:123456789012:my-topic:989c115b-a0c4-4e72-9c12-eea2b3250b7a",
"Owner": "7112345074123",
"Protocol": "email",
"Endpoint": "john.doe@example.com",
"TopicArn": "arn:aws:sns:us-east-1:123456789012:my-topic"
}
]
}
Did you find this article helpful?
If so, consider buying me a coffee over at