1

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!!

  • did you tried to send it locally? I'd try first locally with aws secert and key and check if my code work then I'd check, also have look here for a full exapmle : https://gist.github.com/jeremypruitt/ab70d78b815eae84e037 – A.Elnaggar May 18 '16 at 15:23
  • I ran the code you shared and it sent a message to SNS without issue. I think that issue is the callback that it taking place in my code. @MightyUgh had the same issue on his code over at http://stackoverflow.com/questions/35349521/aws-lambda-calling-sns I am not sure how he solved the issues and I am too new of a user on here to comment on his post. – Thomas Forti May 22 '16 at 03:10

1 Answers1

0

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.

ustundag
  • 3
  • 2