'AWS: SNS SMS how to include message attributes in logs
Context
Right now I'm sending SMS messages using SNS, but without using topics, i.e. directly to the destination phone number. In this action I'm allowed to include "message attributes" (which are basically key-value pairs for metadata).
I have SNS set up to log delivery status of SMS messages to cloudwatch, and then cloudwatch set up to trigger a lambda when these logs are received.
Problem
However, the object received in the logs does not include the message attributes, is there a way to do so ?
Example
The received log looks something like:
{
"notification": {
"messageId": "34d9b400-c6dd-5444-820d-fbeb0f1f54cf",
"timestamp": "2016-06-28 00:40:34.558"
},
"delivery": {
"phoneCarrier": "My Phone Carrier",
"mnc": 270,
"destination": "+1XXX5550100",
"priceInUSD": 0.00645,
"smsType": "Transactional",
"mcc": 310,
"providerResponse": "Message has been accepted by phone carrier",
"dwellTimeMs": 599,
"dwellTimeMsUntilDeviceAck": 1344
},
"status": "SUCCESS"
}
Solution 1:[1]
SNS does not have the capability to deliver message attributes together with delivery status logs today.
What you could do is log the SNS message ID returned during the publish together with the message attributes within your application and correlate them that way.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | bjrnt |
