我正在尝试通过lambda发送publish sns命令,但不会发送 [英] I am trying to send a publish sns command via lambda however it will not send
问题描述
在过去的几天里,我一直在尝试发布sns,但是无论我编写什么代码,我都无法将其发送出去.请注意,我不是编码员,我只是为了好玩而已.
I have been trying for the past days to publish a sns however no matter what i code i just cant get it to send. Be aware i am not a coder, i just do this for fun.
我已经按照以下步骤设置了IAM策略和规则,并使用策略模拟器运行了它,效果很好.
I have set up an IAM policy and rule as below and ran it with the policy simulator and it works fine.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sns:Publish",
"Resource": "arn:aws:sns:us-east-1:*******:CallBell"
}
]
}
我在代码的开头有这个.
i have this at the beginning of my code.
var AWS = require("aws-sdk");
var sns = new AWS.SNS();
然后我将这部分代码包含在我的函数意图之内(这是一种Alexa技能)
I than have this part of the code within my function intent (this is an alexa skill)
console.log("Loading function");
sns.publish({
Message: 'Test',
Subject: 'Test SNS From Lambda',
TopicArn: 'arn:aws:sns:us-east-1:*******:CallBell'
});
console.log("Message Sent");
这让我发疯,需要帮助,我检查了我的日志和加载"功能并发送了消息,但没有出现任何错误,但是我没有收到消息.请帮忙!
This is driving me nuts and need help, I check my log and the Loading function and Message sent and it doesn't give any error however i don't get my messages. Please help!!
推荐答案
如果您在VPC中设置lambda,则它不会路由您的SNS请求.删除VPC后,再试一次.如果您确实需要VPC,则可以在VPC中添加NAT服务,以使lambda能够访问Internet,如
If you set your lambda in a VPC, then it wont route your SNS request. Try again once you remove VPC. If you really need a VPC, you can add a NAT service in your VPC to enable your lambda to have internet access, as explained here.
这篇关于我正在尝试通过lambda发送publish sns命令,但不会发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!