Question: How do I access Amazon SNS topic delivery logs for SMS messages?

I want to access Amazon Simple Notification Service (Amazon SNS) topic delivery logs for SMS messages.

Short descriptionBefore you complete the following steps, confirm that you're using SNS endpoints with support for log delivery status of notification messages:HTTP(S)Amazon Kinesis Data FirehoseAWS LambdaPlatform application endpointAmazon Simple Queue Service (Amazon SQS)SMSNote: If you receive errors when running AWS Command Line Interface (AWS CLI) commands, make sure that you’re using the most recent AWS CLI version.

ResolutionConfigure SMS delivery status attributes for Amazon CloudWatch LogsNote: As an alternative to the following console steps, you can configure message delivery status using AWS SDKs or the AWS CLI.1.    Open the Amazon SNS console.2.    On the navigation pane, expand Mobile, and then choose Text messaging (SMS).3.    In the Text messaging preferences section, choose Edit.4.    Expand Delivery status logging - optional.5.    For Success sample rate, in the % text box, enter 100.Note: Success rate is the percentage of successful message deliveries to the log.6.    In the IAM roles section, for Service role, select Create new service role, and then choose Create new roles. The AWS Identity and Access Management (IAM) console opens.Note: If you already have an IAM role with the right permissions, then you can use that service role by selecting Use existing service role instead.7.    On the IAM console permission request page, choose Allow.8.    After returning to the Amazon SNS console, choose Save changes.Now, an IAM role is created for successful and failed deliveries with the following policy and trust relationships for Amazon SNS.IAM role:arn:aws:iam::1111111111:role/SNSSuccessFeedbackPolicy:{    "Version": "2012-10-17",    "Statement": [        {            "Effect": "Allow",            "Action": [                "logs:CreateLogGroup",                "logs:CreateLogStream",                "logs:PutLogEvents",                "logs:PutMetricFilter",                "logs:PutRetentionPolicy"            ],            "Resource": [                "*"            ]        }    ]}Trust relationships:{  "Version": "2012-10-17",  "Statement": [    {      "Effect": "Allow",      "Principal": {        "Service": "sns.amazonaws.com"      },      "Action": "sts:AssumeRole"    }  ]}View delivery status logs1.    Open the Amazon CloudWatch console.2.    On the navigation pane, expand Logs, and then choose Log groups.3.    In the Filter search box, enter DirectPublishToPhoneNumber to find only SMS log groups for Amazon SNS.Note: Depending on the destination phone number's carrier, it can take up to 72 hours for delivery logs to appear in the Amazon SNS console.For example:The sns/your-AWS-region/your-AWS-account-ID/DirectPublishToPhoneNumber log group contains the successful delivery logs:sns/us-east-1/1111111111/DirectPublishToPhoneNumberSample successful delivery logs:{    "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"}The sns/your-AWS-region/your-AWS-account-ID/DirectPublishToPhoneNumber/Failure log group contains the failure delivery logs:sns/us-east-1/1111111111/DirectPublishToPhoneNumber/FailureSample failure delivery logs:{    "notification": {        "messageId": "1077257a-92f3-5ca3-bc97-6a915b310625",        "timestamp": "2016-06-28 00:40:34.559"    },    "delivery": {        "mnc": 0,        "destination": "+1XXX5550100",        "priceInUSD": 0.00645,        "smsType": "Transactional",        "mcc": 0,        "providerResponse": "Unknown error attempting to reach phone",        "dwellTimeMs": 1420,        "dwellTimeMsUntilDeviceAck": 1692    },    "status": "FAILURE"}4.    Choose the SNS log group that you want to view.5.    On the Log streams tab, choose a particular log stream to view the SMS delivery logs.6.    To see the delivery status of your SMS message, expand the log event and check providerResponse.View opted-out phone numbersRecipients can opt out of receiving SMS messages on their phones from their AWS account. For more information, see Opting out of receiving SMS messages.1.    Open the Amazon SNS console.2.    On the navigation pane, expand the Mobile section, and then choose Text Messaging (SMS).3.    To view opted-out phone numbers, go to the Opted-out phone numbers section.

Related informationMonitoring Amazon SNS topics using CloudWatchSetting SMS messaging preferencesViewing Amazon CloudWatch metrics and logs for SMS deliveries