Unable to deliver worldwide text message from aws lambda function

亡梦爱人 提交于 2019-12-11 00:09:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!