简体   繁体   English

使用 Cloudformation 模板创建两者时,AWS SNS 不会调用 lambda 函数

[英]AWS SNS is not invoking lambda function when both are created using Cloudformation template

I have created lambda and SNS using cloudformation.我已经使用 cloudformation 创建了 lambda 和 SNS。 Here first lambda is invoking a SNS which has a subscription of another lambda.这里第一个 lambda 调用一个 SNS,它订阅了另一个 lambda。 Here SNS is supposed to invoke alias of lambda.这里 SNS 应该调用 lambda 的别名。 In SNS topic lambda ARN is showing as subscriber but in lambda it is not added as trigger.在 SNS 主题 lambda ARN 中显示为订阅者,但在 lambda 中它没有添加为触发器。 There is not a single invocation log of the lambda invoked from SNS.没有从 SNS 调用的 lambda 的单个调用日志。 So is this problem about some kind of permission or else ?那么这个问题是关于某种许可还是其他? need help...需要帮忙...

Yes, this is a permissions issue.是的,这是一个权限问题。 You need to add a permission to the lambda function to allow SNS to invoke it.您需要为 lambda 函数添​​加权限以允许 SNS 调用它。

Use the AWS::Lambda::Permission resource to add permissions to allow SNS to invoke the lambda function.使用AWS::Lambda::Permission资源添加权限以允许 SNS 调用 lambda 函数。

I had a heck of a time with one.我和一个玩得很开心。 I had originally set my lambda function to look for an event source of "aws:s3".我最初将我的 lambda 函数设置为查找“aws:s3”的事件源。 In order to get the event source from an s3 event, I used "event.Records[0].eventSource".为了从 s3 事件中获取事件源,我使用了“event.Records[0].eventSource”。 When I tested event.Records[0].eventSource == "aws:sns" to check if my SNS trigger had fired, it wouldn't work.当我测试 event.Records[0].eventSource == "aws:sns" 以检查我的 SNS 触发器是否已触发时,它不起作用。 It wasn't until I found sample SNS event JSON that I noticed that SNS events have an event source node of "EventSource".直到我找到示例 SNS 事件 JSON,我才注意到 SNS 事件具有“EventSource”的事件源节点。 It's capital case.这是资本案件。 I changed my test to我改变了我的测试

event.Records[0].EventSource == "aws:sns" 

and it worked.它奏效了。 So much for consistency in event message formats.事件消息格式的一致性就到此为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为使用 CloudFormation 模板创建的 AWS Lambda function 添加触发器? - How to add triggers for a AWS Lambda function created using a CloudFormation template? 使用 cloudformation 创建时,sns 无法触发 lambda - sns unable to trigger lambda when created using cloudformation 适用于Lambda和SNS的AWS CloudFormation主题 - AWS CloudFormation for Lambda and SNS Topic 我可以使用 CloudFormation 模板更新 AWS Lambda function 吗? - Can I update AWS Lambda function using CloudFormation template? 如何使用 CloudFormation 模板更新 AWS Lambda function - How do I update AWS Lambda function using CloudFormation template aws cloudformation 模板 sns sqs - aws cloudformation template sns sqs 授予对 lambda 函数别名的 SNS 调用访问权限,同时使用 CDK 在单独的堆栈中创建 SNS 和 lambda 函数 - Granting SNS invoke access to a lambda function's alias while both SNS and the lambda function are created in seperate stacks using CDK AWS SNS 没有通过另一个 Lambda 调用 Lambda - AWS SNS is not invoking Lambda through another Lambda 使用来自不同账户的 Amazon lambda 调用 AWS SNS? - Invoking AWS SNS using Amazon lambda from Different Accounts? 使用 CloudFormation 时,AWS Lambda function 缺少 websocket 网关触发 - AWS Lambda function is missing trigger by websocket gateway when using CloudFormation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM