AWS Lambda& SNS:调用Lambda跨区域

编程入门 行业动态 更新时间:2024-10-28 19:34:27
本文介绍了AWS Lambda& SNS:调用Lambda跨区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我将Lambda函数部署到了多个区域.我想向SNS发布一条消息,这些消息将调用这些功能.

I have a Lambda function deployed to several regions. I would like to publish a message to SNS that will invoke these functions.

使用aws-cli,我已经创建了主题,并赋予Lambda与SNS对话的权限,并创建了订阅.订阅似乎已成功创建,并且可以在AWS控制台中看到它.但是,它不起作用. lambda函数不会被调用.

Using aws-cli I've created the topics, given Lambda permission to talk to SNS, and create the subscriptions. The subscription appears to be created successfully, and I can see it in the AWS console. But, it doesn't work. The lambda function does not get invoked.

推荐答案

这是基于CloudFormation的示例.您必须将SNS的调用权限添加到Lambda函数中:

This is CloudFormation based example. You have to add invoke permission for SNS to the Lambda functions:

{ "Type" : "AWS::Lambda::Permission", "Properties" : { "FunctionName" : { "Fn::GetAtt" : [ "YourLambda", "Arn" ] }, "Action" : "lambda:InvokeFunction", "Principal" : "sns.amazonaws", "SourceArn" : { "Ref" : "YourSNSTopicArn" } } }

然后,您需要将Lambdas订阅到SNS主题.这可以通过API调用或通过CloudFormation来完成.

Then you need to subscribe your Lambdas to your SNS topic. This can be done via API call or through CloudFormation.

{ "Type" : "AWS::SNS::Topic", "Properties" : { "TopicName" : "YourTopicName", "Subscription" : [ { "Endpoint" : { "Fn::GetAtt" : [ "YourLambda", "Arn" ] }, "Protocol": "lambda" } ] } }

如果您缺少任何一个,则不会调用您的Lambdas.以上信息的来源是官方博客文章调用Lambda通过SNS功能.

If you're missing any of this, your Lambdas won't invoke. Source for the above information is the official blog article Invoking Lambda functions via SNS.

更多推荐

AWS Lambda& SNS:调用Lambda跨区域

本文发布于:2023-11-06 14:56:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564005.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Lambda   AWS   SNS   amp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!