I had what I believe is more of an edge-case compared to the above more common scenarios, but my solution may still be of benefit to someone who ends up in the frustrating situation I was in! I was sending SMS text messages using the SNS API for several months and then suddenly the sending began failing to the one destination country's mobile network - for no apparent reason. Reaching out to AWS support did not provide much insight besides them saying the destination network had an issue with the incoming message and I needed to investigate further myself.
This was the SNS sending error in cloudwatch:
...
"delivery": {
"mnc": 10,
"numberOfMessageParts": 1,
"destination": "+27*********",
"priceInUSD": 0.0198,
"smsType": "Promotional",
"mcc": 655,
"providerResponse": "Unknown error attempting to reach phone",
"dwellTimeMs": 679,
"dwellTimeMsUntilDeviceAck": 2026
},
"status": "FAILURE"
...
After much research and experimentation, obtaining an official origination number from AWS PinPoint and specifying this origination number in the SNS API call resulted in the SNS SMS being sent successfully again.
Note: Also do your homework as to whether the target mobile network allows (or requires) Sender Id's - I was also initially setting a Sender Id, but had to remove this too before the above solution worked.
Here is the link to obtaining an origination number (I used a USA long code for my solution which costs $2 per month...): https://docs.aws.amazon.com/pinpoint/latest/userguide/settings-sms-request-number.html
The following python (Boto3) code sample shows how to set the origination number in the SNS call:
response = sns_client.publish(
PhoneNumber='+27*********',
Message='test',
MessageAttributes={
'AWS.SNS.SMS.SMSType': {
'DataType': 'String',
'StringValue': 'Promotional'
},
'AWS.MM.SMS.OriginationNumber': {
'DataType': 'String',
'StringValue': '+1**********'
}
}
)