问题
I am trying to send OTP from my AWS Lambda function hosted in AP-South-1 (i.e. Mumbai) region. I am using a worldwide text-messaging feature of SNS for this. As the "AP-South-1" region does not support worldwide text-messaging feature, I am sending the SNSClient's region endpoint as "APNortheast1" (i.e. Tokyo) region as it supports worldwide text-messaging.
Now, I have given my lambda function administrator privilege (by attaching role with administrator policy). But, still, it doesn't seem to be working (not delivering the message to my mobile). I am not getting any exception while executing the function and I am also getting the "TransactionID" for that SMS. In the SNS console, the SMS is showing as failed. So, I have enabled the cloudwatch log for it. The log I am getting is below-
{
"notification": {
"messageId": "8cba93de-b794-577d-99be-c1ba5d5d21dd",
"timestamp": "2017-10-21 06:26:17.946"
},
"delivery": {
"destination": "+91XXXXXXXXXX",
"smsType": "Transactional",
"providerResponse": "Internal error",
"dwellTimeMs": 79
},
"status": "FAILURE"
}
Now, here is the irony- this is actually a new account where I am migrating (manually) the resources from another account. In this older account, I have the exact same setup, but it seems to be delivering the message properly to my mobile. For your information, my Lambda function is written in the .net core and I am trying to deliver the SMS to an Indian mobile number.
回答1:
As of October 2017, Amazon SNS supports SMS messaging in the following regions:
- US East (N. Virginia)
- US West (Oregon)
- EU (Ireland)
- Asia Pacific (Tokyo)
- Asia Pacific (Singapore)
- Asia Pacific (Sydney)
A quick way to send an SMS is with the AWS Command-Line Interface (CLI):
aws sns publish --phone-number 9112345678 --message foo --region ap-southeast-2
This fails when using ap-south-1
, because SMS is not supported in that region.
Your Lambda code can send the message via another region, but you will need to create your SNS client object in a different region.
来源:https://stackoverflow.com/questions/46860820/unable-to-deliver-worldwide-text-message-from-aws-lambda-function