AWS Lambda调用SNS [英] AWS Lambda calling SNS

查看:85
本文介绍了AWS Lambda调用SNS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与我的Amazon Echo一起玩,并编写了一个小功能,希望在女儿回复后发短信给我.代码执行得很好-但是sns.publish永远不会发生.它无声地失败-我无法引发错误.我相信我拥有适当的IAM权限和主题订阅.有人可以帮忙吗?

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);
    });
}

推荐答案

我遇到了同样的问题,并通过将发布参数更改为以下内容来解决了该问题,

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!

这篇关于AWS Lambda调用SNS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆