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

Using Amazon SNS Topic Attributes for Message Delivery Status

Amazon SNS provides support to log the delivery status of notification messages sent to topics with the following Amazon SNS endpoints:

  • Application

  • HTTP

  • Lambda

  • SQS

After you configure the message delivery status attributes, log entries will be sent to CloudWatch Logs for messages sent to a topic subscribed to an Amazon SNS endpoint. Logging message delivery status helps provide better operational insight, such as the following:

  • Knowing whether a message was delivered to the Amazon SNS endpoint.

  • Identifying the response sent from the Amazon SNS endpoint to Amazon SNS.

  • Determining the message dwell time (the time between the publish timestamp and just before handing off to an Amazon SNS endpoint).

To configure topic attributes for message delivery status, you can use the AWS Management Console, AWS software development kits (SDKs), or query API.

Configuring Message Delivery Status Attributes with the AWS Management Console

The following steps describe how to use the console to configure the message delivery status attributes for notifications from Amazon SNS to a AWS Lambda endpoint.

To configure message delivery status for notifications from Amazon SNS to a Lambda endpoint:

  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, click Topics, and then click the topic to which you want to receive message delivery status information.

  3. Click Actions and then click Delivery status.

  4. Click the Lambda check box.

  5. On the Delivery Status dialog box, click Create IAM Roles.

    You will then be redirected to the IAM console.

  6. Click Allow to give Amazon SNS write access to use CloudWatch Logs on your behalf.

  7. Switch back to the Delivery Status dialog box and enter a number in the Percentage of Success to Sample (0-100) field for the percentage of successful messages sent for which you want to receive CloudWatch Logs.

    Note

    After you configure application attributes for message delivery status, all failed message deliveries generate CloudWatch Logs.

  8. Finally, click Save Configuration.

    You will now be able to view and parse the CloudWatch Logs containing the message delivery status. For more information about using CloudWatch, see the CloudWatch Documentation.

Configuring Message Delivery Status Attributes for Topics Subscribed to Amazon SNS Endpoints with the AWS SDKs

The AWS SDKs provide APIs in several languages for using message delivery status attributes with Amazon SNS.

Topic Attributes

You can use the following topic attribute name values for message delivery status:

Application

  • ApplicationSuccessFeedbackRoleArn

  • ApplicationSuccessFeedbackSampleRate

  • ApplicationFailureFeedbackRoleArn

    Note

    In addition to being able to configure topic attributes for message delivery status of notification messages sent to Amazon SNS application endpoints, you can also configure application attributes for the delivery status of push notification messages sent to push notification services. For more information, see Using Amazon SNS Application Attributes for Message Delivery Status.

HTTP

  • HTTPSuccessFeedbackRoleArn

  • HTTPSuccessFeedbackSampleRate

  • HTTPFailureFeedbackRoleArn

Lambda

  • LambdaSuccessFeedbackRoleArn

  • LambdaSuccessFeedbackSampleRate

  • LambdaFailureFeedbackRoleArn

SQS

  • SQSSuccessFeedbackRoleArn

  • SQSSuccessFeedbackSampleRate

  • SQSFailureFeedbackRoleArn

The <ENDPOINT>SuccessFeedbackRoleArn and <ENDPOINT>FailureFeedbackRoleArn attributes are used to give Amazon SNS write access to use CloudWatch Logs on your behalf. The <ENDPOINT>SuccessFeedbackSampleRate attribute is for specifying the sample rate percentage (0-100) of successfully delivered messages. After you configure the <ENDPOINT>FailureFeedbackRoleArn attribute, then all failed message deliveries generate CloudWatch Logs.

Java Example to Configure Topic Attributes

The following Java example shows how to use the SetTopicAttributes API to configure topic attributes for message delivery status of notification messages sent to topics subscribed to Amazon SNS endpoints. In this example, it is assumed that string values have been set for topicArn, attribName, and attribValue.

Copy
final static String topicArn = ("arn:aws:sns:us-east-2:123456789012:MyTopic"); final static String attribName = ("LambdaSuccessFeedbackRoleArn"); final static String attribValue = ("arn:aws:iam::123456789012:role/SNSSuccessFeedback");
Copy
SetTopicAttributesRequest setTopicAttributesRequest = new SetTopicAttributesRequest(); setTopicAttributesRequest.withTopicArn(topicArn); setTopicAttributesRequest.setAttributeName(attribName); setTopicAttributesRequest.setAttributeValue(attribValue);

For more information about the SDK for Java, see Getting Started with the AWS SDK for Java.