Amazon Simple Notification Service
Developer Guide (API Version 2010-03-31)

Getting Started with Amazon Simple Notification Service

This section contains information for you to understand Amazon SNS concepts and quickly set up and use available tools and interfaces for creating and publishing to topics. To get started with push notification messages, see Using Amazon SNS for User Notifications with a Mobile Application as a Subscriber (Mobile Push).

Before You Begin

To use Amazon SNS, you need an AWS account. If you don't already have one, use the following procedure.

To sign up for AWS account

  1. Open https://aws.amazon.com/, and then choose Create an AWS Account.

    Note

    If you previously signed in to the AWS Management Console using AWS account root user credentials, choose Sign in to a different account. If you previously signed in to the console using IAM credentials, choose Sign-in using root account credentials. Then choose Create a new AWS account.

  2. Follow the online instructions.

    Part of the sign-up procedure involves receiving a phone call and entering a verification code using the phone keypad.

To get started with Amazon SNS

  1. Sign in to the AWS Management Console and open the Amazon SNS console at https://console.aws.amazon.com/sns/v2/home.

  2. Choose the Get Started button.

    You should now be on the SNS Home page.

Create a Topic

Now that you're signed up for Amazon SNS, you're ready to create a topic. A topic is a communication channel to send messages and subscribe to notifications. It provides an access point for publishers and subscribers to communicate with each other. In this section you create a topic named MyTopic.

To create a topic

  1. In the Amazon SNS console, choose Create topic.

    The Create topic dialog box appears.

  2. In the Topic name box, type a topic name.

  3. Choose Create topic.

  4. On the Topic Details page, select the new topic and then choose the topic ARN.

  5. Copy the topic ARN.

    arn:aws:sns:us-west-2:111122223333:MyTopic

Subscribe to a Topic

To receive messages published to a topic, you have to subscribe an endpoint to that topic. An endpoint is a mobile app, web server, email address, or an Amazon SQS queue that can receive notification messages from Amazon SNS. Once you subscribe an endpoint to a topic and the subscription is confirmed, the endpoint will receive all messages published to that topic.

In this section you subscribe an endpoint to the topic you just created in the previous section. You configure the subscription to send the topic messages to your email account.

To subscribe to a topic

  1. Open the Amazon SNS console at https://console.aws.amazon.com/sns/v2/home.

  2. Choose Create subscription.

    The Create Subscription dialog box appears.

  3. In the Topic ARN field, paste the topic ARN you created in the previous task, for example: arn:aws:sns:us-west-2:111122223333:MyTopic.

  4. In the Protocol drop-down box, select Email.

  5. In the Endpoint box, type an email address you can use to receive the notification.

    Important

    Entourage Users: Entourage strips out the confirmation URL. Type an email address you can access in a different email application.

  6. Choose Create subscription.

  7. Go to your email application and open the message from AWS Notifications, and then choose the link to confirm your subscription.

    Your web browser displays a confirmation response from Amazon SNS.

Publish to a Topic

Publishers send messages to topics. Once a new message is published, Amazon SNS attempts to deliver that message to every endpoint that is subscribed to the topic. In this section you publish a message to the email address you defined in the previous task.

To publish to a topic

  1. Open the Amazon SNS console at https://console.aws.amazon.com/sns/v2/home.

    In the left navigation pane, choose Topics and then select the topic you want to publish to.

  2. Choose the Publish to topic button.

    The Publish a Message page appears.

  3. In the Subject box, type a subject line for your message.

  4. In the Message box, type a brief message.

  5. Choose Publish Message.

    A confirmation dialog box appears.

You can now use your email application to open the message from AWS Notifications and read the message.

Create Different Messages for Each Protocol

You can use message formatting support to customize the messages you send for each protocol. For example, a notification that goes to both email and SMS subscribers can be tailored to each type of client. SMS users can receive a short version of the message, while email users can receive a longer, more detailed version.

To publish to a topic with message formatting

  1. Sign in to the AWS Management Console and open the Amazon SNS console at https://console.aws.amazon.com/sns/v2/home.

  2. In the left navigation pane, choose Topics and then select a topic.

  3. Choose the Publish to topic button.

    The Publish a message page appears.

  4. Choose the JSON Message Generator button.

  5. In the Message box, type a brief message.

  6. In this example for the Target Platforms, select email and sms.

  7. Choose the Generate JSON button.

    You can now modify the message text so that it is tailored to each type of client.

    The SMS message can contain up to 160 ASCII (or 70 Unicode) characters. If the message exceeds this length, Amazon SNS sends it as multiple messages, each fitting within the character limit. Messages are not cut off in the middle of a word but on whole-word boundaries.

    Email messages can be up to 256 KB in size.

    In the following example, messages are specified for the default, email, and SMS protocols.

    { "default": "Message body text here.", "email": "Message body text here.", "sms": "Message body text here." }
  8. Choose Publish message.

    A confirmation dialog box appears.

Clean Up

You have created a topic, subscribed to it, and published a message to the topic. Now you clean up your environment by unsubscribing from the topic and then deleting the topic.

To unsubscribe from a topic

  1. Open the Amazon SNS console at https://console.aws.amazon.com/sns/v2/home.

    In the left navigation pane, choose Subscriptions.

    The Subscriptions page opens.

  2. Select your subscription in the subscription list. This will be the only listing on the page, unless you created more than one subscription.

  3. Choose the Actions drop-down list and then choose Delete subscription(s).

    The Delete confirmation dialog box appears.

  4. Choose Delete.

The subscription is deleted, unless it is a pending subscription, meaning it has not yet been confirmed. You cannot delete a pending subscription, but if it remains pending for 3 days, Amazon SNS automatically deletes it.

To delete a topic

Open the Amazon SNS console at https://console.aws.amazon.com/sns/v2/home.

  1. In the left navigation pane, choose Topics, and then select the topic you want to delete.

  2. Choose the Actions drop-down list and select Delete topics.

    The Delete confirmation dialog box appears.

  3. Choose Delete.

    When you delete a topic, you also delete all subscriptions to that topic.