问题
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.
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();
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!!
回答1:
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.
来源:https://stackoverflow.com/questions/36961089/i-am-trying-to-send-a-publish-sns-command-via-lambda-however-it-will-not-send