Can't create a SNS Event source on a Lambda function using CloudFormation

非 Y 不嫁゛ 提交于 2019-12-03 04:58:56

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

Adding the proper function name and sourcearn in permissions helped solving the issue

"MySNSTopic": {
            "Type": "AWS::SNS::Topic",
            "Properties": {
                "TopicName": "MyTopic",
                "DisplayName": "My Test Topic",
                "Subscription": [
                {
                    "Endpoint": { "Fn::GetAtt" : ["Lambda", "Arn"] },
                    "Protocol": "lambda"
                }
                ]
            }
    },
    "PermissionForEventsToInvokeLambda": {
          "Type": "AWS::Lambda::Permission",
          "Properties": {
            "FunctionName": { "Fn::GetAtt" : ["Lambda", "Arn"] },
            "Action": "lambda:InvokeFunction",
            "Principal": "sns.amazonaws.com",
            "SourceArn": { "Ref": "MySNSTopic" }
          }
      }
   },
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!