AWS Lambda calling SNS

最后都变了- 提交于 2020-01-16 20:00:31

问题


I'm playing with my Amazon Echo and wrote a little function which I hope would text me after a response from my daughter. The code executes fine - but the sns.publish never happens. It fails silently - I can't raise an error. I believe I have the proper IAM permissions and Topic subscriptions. Can someone help?

function textMom(kindOfDay){
    var message = "Test";
    var sns = new AWS.SNS();
    console.log("textMethod")

    sns.publish({
        TopicArn: "arn:aws:sns:us-east-1:",
        Message: message
    }, function(err, data) {
        if(err) {
            console.log('error publishing to SNS');
            context.fail(err);
        } else {
            console.log('message published to SNS');
            context.done(null, data);
        }
        console.log(data);
    });
}

回答1:


I encountered the same problem, and solved by changing publish parameters to below,

sns.publish(params, context.done);

This help me to check my function is completed before all calls have finished. Try it!



来源:https://stackoverflow.com/questions/35349521/aws-lambda-calling-sns

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