无法通过AWS Lambda函数传递全球短信 [英] Unable to deliver worldwide text message from aws lambda function
问题描述
我试图从托管在AP-South-1(即孟买)区域的AWS Lambda函数发送OTP.为此,我正在使用SNS的全球短信功能.由于"AP-South-1"区域不支持全球范围内的文本消息功能,因此我将SNSClient的区域终结点发送为"APNortheast1"(即东京)区域,因为它支持全球范围内的文本消息.
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.
现在,我已给我的lambda函数管理员权限(通过在角色上附加管理员策略).但是,它似乎仍然不起作用(无法将消息传递到我的手机上).在执行功能时,我没有收到任何异常,并且我也收到了该SMS的"TransactionID".在SNS控制台中,SMS显示为失败.因此,我已经为其启用了cloudwatch日志.我得到的日志如下-
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"
}
现在,具有讽刺意味的是-这实际上是一个新帐户,我正在其中(手动)从另一个帐户中迁移资源.在这个较旧的帐户中,我的设置完全相同,但是似乎可以正确地将消息传递到我的手机上.为了给您提供信息,我的Lambda函数编写在.net核心中,我正尝试将SMS传递到印度的手机号码.
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.
推荐答案
截至2017年10月,Amazon SNS支持SMS消息传递
As of October 2017, Amazon SNS supports SMS messaging in the following regions:
- 美国东部(弗吉尼亚北部)
- 美国西部(俄勒冈州)
- 欧盟(爱尔兰)
- 亚太地区(东京)
- 亚太地区(新加坡)
- 亚太地区(悉尼)
使用 AWS命令行界面(CLI)是发送SMS的快速方法. :
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
使用ap-south-1
时此操作失败,因为该区域不支持SMS.
This fails when using ap-south-1
, because SMS is not supported in that region.
您的Lambda代码可以通过其他区域发送消息,但是您需要在其他区域创建SNS客户端对象.
Your Lambda code can send the message via another region, but you will need to create your SNS client object in a different region.
这篇关于无法通过AWS Lambda函数传递全球短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!