I am trying to send a publish sns command via lambda however it will not send

╄→尐↘猪︶ㄣ 提交于 2021-01-29 03:52:09

问题


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

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