AWS Lambda & SNS: Call Lambda Cross Region

I have a Lambda function deployed in several regions. I would like to post an SNS message that will call these functions.

Using aws-cli, I created themes, given Lambda’s permission to talk to SNS and create subscriptions. The subscription may have been created successfully, and I can see it in the AWS console. But that will not work. The lambda function is not activated.

+4
source share
1 answer

This is an example CloudFormation. You must add permission for SNSfor functions Lambda:

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

Lambdas SNS . API CloudFormation.

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

, Lambdas . SNS.

+5

Source: https://habr.com/ru/post/1625935/


All Articles