本文介绍了无法使用CloudFormation在Lambda函数上创建SNS事件源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是与我的问题有关的 Cloudformation 模板代码:

This is the Cloudformation template code related to my problem:

"SNSTopic": {
  "Type": "AWS::SNS::Topic",
  "Properties": {
    "TopicName": "JumpboxPresenceTopic",
    "DisplayName": "Jumpbox Presence Topic",
    "Subscription": [
      {
        "Endpoint": {
          "Fn::GetAtt": [
            "Lambda",
            "Arn"
          ]
        },
        "Protocol": "lambda"
      }
    ]
  }
},
"Lambda": {
  "Type": "AWS::Lambda::Function",
  "Properties": [...]

我可以在 SNS 仪表板中看到该主题:

I can see the topic in the SNS dashboard:

,但它不会显示在lambda函数 Event Sources 面板中:

But it does not display in the lambda function Event Sources panel:

关于这一点的怪异之处在于,如果我创建了一个来自 SNS 仪表板的同一lambda函数的新订阅,因此不会创建新的订阅,因为它将完全相同。但是,现在,如果我查看了 Lambda仪表板中的 Event Sources 面板,则可以看到 SNS的新条目:JumpboxPresenceTopic

The weird thing about this, is that if I create a new subscription from the SNS dashboard for that same lambda function, no new subscription is created since it would be an exact duplicate. However, now if I check the Event Sources panel in the Lambda dashboard, I can see a new entry for the SNS: JumpboxPresenceTopic:

我觉得这是亚马逊方面的问题,但我可能是错的。我的方法有问题吗?还是AWS的限制?

I feel like it's an issue on Amazon's side but I could be wrong. Is there something wrong with my approach or is it a limitation of AWS ?

推荐答案

您必须授予SNS权限才能首先调用Lambda。
这是AWS的示例。请将其从S3更改为SNS,并且不要忘记将SourceArn设置为SNS主题ARN。

You must grant SNS permission to invoke Lambda first.Here is a example from AWS. Please change it from S3 to SNS and don't forget to set SourceArn as the SNS Topic ARN.

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-permission.html

这篇关于无法使用CloudFormation在Lambda函数上创建SNS事件源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 12:48