How can I use CloudWatch Logs to monitor delivery of Amazon SNS text messages?
Last updated: 2020-12-17
How can I use Amazon CloudWatch Logs to monitor that text messages sent through Amazon Simple Notification Service (Amazon SNS) are being delivered?
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
- Open the Amazon SNS console.
- Open the left navigation menu, expand Mobile, and then choose Text messaging (SMS).
- On the Mobile text messaging (SMS) page, next to Text messaging preferences, choose Edit.
- On the Edit text messaging preferences page, expand Delivery status logging - optional.
- Under the IAM roles section, choose Create new service role.
- Choose Create new roles. The AWS Identity and Access Management (IAM) console appears.
- On the IAM console permission request page, choose Allow.
- Choose Save changes.
Send a test SMS message
- In the Amazon SNS console, on the Mobile text messaging (SMS) page, choose Publish text message.
- 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.
- Choose Publish message. The phone number you entered should receive the test SMS message.
Check the provider response logs
- Open the CloudWatch console.
- In the left navigation pane, choose Logs, and then choose Log groups.
- In the Filter field, enter sns to find only log groups for Amazon SNS.
- Choose the group with DirectPublishToPhoneNumber in its name.
Note: Log groups with Failure appended to the end of the name are for failed 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.