Amazon SNS raw message delivery - Amazon Simple Notification Service

Amazon SNS raw message delivery

To avoid having Amazon Data Firehose, Amazon SQS, and HTTP/S endpoints process the JSON formatting of messages, Amazon SNS allows raw message delivery:

  • When you enable raw message delivery for Amazon Data Firehose or Amazon SQS endpoints, any Amazon SNS metadata is stripped from the published message and the message is sent as is.

  • When you enable raw message delivery for HTTP/S endpoints, the HTTP header x-amz-sns-rawdelivery with its value set to true is added to the message, indicating that the message has been published without JSON formatting.

  • When you enable raw message delivery for HTTP/S endpoints, the message body, client IP, and the required headers are delivered. When you specify message attributes, it won't be sent.

  • When you enable raw message delivery for Firehose endpoints, the message body is delivered. When you specify message attributes, it won't be sent.

To enable raw message delivery using an AWS SDK, you must use the SetSubscriptionAttribute API action and set the value of the RawMessageDelivery attribute to true.

Enabling raw message delivery using the AWS Management Console

  1. Sign in to the Amazon SNS console.

  2. On the navigation panel, choose Topics.

  3. On the Topics page, choose a topic subscribed to an Firehose, Amazon SQS, or HTTP/S endpoint.

  4. On the MyTopic page, in the Subscription section, choose a subscription and choose Edit.

  5. On the Edit EXAMPLE1-23bc-4567-d890-ef12g3hij456 page, in the Details section, choose Enable raw message delivery.

  6. Choose Save changes.

Message format examples

In the following examples, the same message is sent to the same Amazon SQS queue twice. The only difference is that raw message delivery is disabled for the first message, and enabled for the second.

  • Raw message delivery is disabled

    { "Type": "Notification", "MessageId": "dc1e94d9-56c5-5e96-808d-cc7f68faa162", "TopicArn": "arn:aws:sns:us-east-2:111122223333:ExampleTopic1", "Subject": "TestSubject", "Message": "This is a test message.", "Timestamp": "2021-02-16T21:41:19.978Z", "SignatureVersion": "1", "Signature": "FMG5tlZhJNHLHUXvZgtZzlk24FzVa7oX0T4P03neeXw8ZEXZx6z35j2FOTuNYShn2h0bKNC/zLTnMyIxEzmi2X1shOBWsJHkrW2xkR58ABZF+4uWHEE73yDVR4SyYAikP9jstZzDRm+bcVs8+T0yaLiEGLrIIIL4esi1llhIkgErCuy5btPcWXBdio2fpCRD5x9oR6gmE/rd5O7lX1c1uvnv4r1Lkk4pqP2/iUfxFZva1xLSRvgyfm6D9hNklVyPfy+7TalMD0lzmJuOrExtnSIbZew3foxgx8GT+lbZkLd0ZdtdRJlIyPRP44eyq78sU0Eo/LsDr0Iak4ZDpg8dXg==", "SigningCertURL": "https://sns.us-east-2.amazonaws.com/SimpleNotificationService-010a507c1833636cd94bdb98bd93083a.pem", "UnsubscribeURL": "https://sns.us-east-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-2:111122223333:ExampleTopic1:e1039402-24e7-40a3-a0d4-797da162b297" }
  • Raw message delivery is enabled

    This is a test message.

Message attributes and raw message delivery for Amazon SQS subscriptions

Amazon SNS supports the delivery of message attributes, which allow you to provide structured metadata items, such as timestamps, geospatial data, signatures, and identifiers, about the message. For Amazon SQS subscriptions with Raw Message Delivery enabled, a maximum of 10 message attributes can be sent. To send more than 10 message attributes, you must disable Raw Message Delivery. However, Amazon SNS discards messages with more than 10 message attributes directed towards Amazon SQS subscriptions with Raw Message Delivery enabled, treating them as client-side errors.