Getting Started with Amazon SNS
This section helps you become more familiar with Amazon SNS by showing you how to manage topics, subscriptions, and messages using the AWS Management Console.
Prerequisites
Before you begin, complete the steps in Setting Up Access for Amazon SNS.
Step 1: Create a Topic
-
Sign in to the Amazon SNS console.
-
In the Create topic section, enter a Topic name, for example
MyTopic
. -
Choose Create topic.
The topic is created and the
MyTopic
page is displayed.The topic's Name, ARN, (optional) Display name, and Topic owner's AWS account ID are displayed in the Details section.
-
Copy the topic ARN to the clipboard, for example:
arn:aws:sns:us-east-2:123456789012:MyTopic
Step 2: Create a Subscription for an Endpoint to the Topic
-
On the navigation panel, choose Subscriptions.
-
On the Subscriptions page, choose Create subscription.
-
On the Create subscription page, do the following:
-
Enter the Topic ARN of the topic you created earlier, for example:
arn:aws:sns:us-east-2:123456789012:MyTopic
Note
To see a list of the topics in the current AWS account, choose the Topic ARN field.
-
For Protocol, select an endpoint type, for example Email.
-
For Endpoint, enter an email address that can receive notifications, for example:
name@example.com
Note
After your subscription is created, you must confirm it. Only HTTP/S endpoints, email addresses, and AWS resources in other AWS accounts require confirmation. (Amazon SQS queues and Lambda functions in the same AWS account—as well as mobile endpoints —don't require confirmation.)
-
Choose Create subscription.
The subscription is created and the
Subscription: 1234a567-bc89-012d-3e45-6fg7h890123i
page is displayed.The subscription's ARN, Endpoint, Topic, Status (Pending confirmation at this stage), and Protocol are displayed in the Details section.
-
-
In your email client, check the email address that you specified and choose Confirm subscription in the email from Amazon SNS.
-
In your web browser, a subscription confirmation with your subscription ID is displayed.
Step 3: Publish a Message to the Topic
-
On the navigation panel, choose Topics.
-
On the Topics page, choose the topic you created earlier and then choose Publish message.
-
On the Publish message to topic page, do the following:
-
In the Message details section, enter the (optional) Subject, for example:
Hello from Amazon SNS!
-
In the Message body section, enter the message, for example:
If you receive this message, publishing a message to an Amazon SNS topic works.
-
In the Message attributes section, add any attributes that you want Amazon SNS to match with the subscription attribute
FilterPolicy
to decide whether the subscribed endpoint is interested in the published message. For more information, see Amazon SNS Message Attributes. -
Choose Publish message.
The message is published to the topic and the
MyTopic
page is displayed.The topic's Name, ARN, (optional) Display name, and Topic owner's AWS account ID are displayed in the Details section.
-
-
In your email client, check the email address that you specified earlier and read the email from Amazon SNS.
Step 4: Delete the Subscription and Topic
-
On the navigation panel, choose Subscriptions.
-
On the Subscriptions page, choose a confirmed subscription and then choose Delete.
Note
You can't delete a pending confirmation. After 3 days, Amazon SNS deletes it automatically.
-
In the Delete subscription dialog box, choose Delete.
The subscription is deleted.
-
On the navigation panel, choose Topics.
-
On the Topics page, choose a topic and then choose Delete.
Important
When you delete a topic, you also delete all subscriptions to the topic.
-
On the Delete topic
MyTopic
dialog box, enterdelete me
and then choose Delete.The topic is deleted.
Next Steps
Now that you've created a topic and a subscription and learned how to send messages to a topic and how to delete a subscription and topic, you might want to try the following:
-
Enable server-side encryption for a topic with an encrypted Amazon SQS queue subscribed.
-
Deploy and test the AWS Event Fork Pipelines sample application.
-
Learn how to interact with Amazon SNS programmatically by exploring the AWS Developer Center.
-
Learn about keeping an eye on costs and resources in the Amazon SNS Monitoring and Logging section.
-
Learn about protecting your data and access to it in the Security section.