How can I use CloudWatch Logs to monitor delivery of Amazon SNS text messages?

Last updated: 2019-04-10

How can I use Amazon CloudWatch Logs to monitor that text messages sent through Amazon Simple Notification Service (Amazon SNS) are being delivered? 

Resolution

Configure CloudWatch Logs for text messages sent through Amazon SNS. You can then view logs of successful and failed message deliveries.

Configure text messaging preferences

  1. Open the Amazon SNS console.
  2. Open the left navigation menu, expand Mobile, and then choose Text messaging (SMS).
  3. On the Mobile text messaging (SMS) page, next to Text messaging preferences, choose Edit.
  4. On the Edit text messaging preferences page, expand Delivery status logging - optional.
  5. Under the IAM roles section, choose Create new service role.
  6. Choose Create new roles. The AWS Identity and Access Management (IAM) console appears.
  7. On the IAM console permission request page, choose Allow.
  8. Choose Save changes.

Send a test SMS message

  1. In the Amazon SNS console, on the Mobile text messaging (SMS) page, choose Publish text message.
  2. Under Publish SMS message, do the following:
    For Message type, choose Transactional.
    For Phone number, enter the phone number where you want to receive your test SMS message.
    For Message, enter the message body of your test SMS message.
    For Sender ID - optional, if you want, enter a customer sender ID.
  3. Choose Publish message. The phone number you entered should receive the test SMS message.

Check the provider response logs

  1. Open the CloudWatch console.
  2. In the left navigation pane, choose Logs.
  3. In the Filter field, enter sns to find only log groups for Amazon SNS.
  4. Choose the group with DirectPublishToPhoneNumber in its name.
    Note: Log groups with Failure appended to the end of the name are for failed deliveries. For more information and troubleshooting, see How do I troubleshoot failed Amazon SNS push notification deliveries?
  5. Under Log Streams, choose the ID of the log stream.
  6. Expand the log event. For providerResponse, you'll see "Message has been accepted by phone".

View opted-out phone numbers

Recipients can opt out their phone numbers from receiving SMS messages from your AWS account. For more information, see Opting Out of Receiving SMS Messages.

To view opted-out phone numbers, check Opted-out phone numbers on the Mobile text messaging (SMS) page of the Amazon SNS console.