Why doesn't SNS fire my lambda?

I have an AWS lambda function that I created through the top. I also created an SNS theme and a subscription via terraform.

My topic: arn:aws:sns:ap-southeast-1:178284945954:fetch_realm_auctions

I have a subscription: arn:aws:sns:ap-southeast-1:178284945954:fetch_realm_auctions:2da1d182-946d-4afd-91cb-1ed3453c5d86 with type lambda , and the endpoint: arn:aws:lambda:ap-southeast-1:178284945954:function:wowauctions_get_auction_data

I have confirmed that this is the correct ARN function. Everything seems to be connected correctly:

SNS Image

I start SNS manually:

 aws sns publish --topic-arn arn:aws:sns:ap-southeast-1:178284945954:fetch_realm_auctions --message '{"endpoint": "https://us.api.battle.net", "realm": "spinebreaker"}' 

It returns a message id, but no call is made. Why?

+5
source share
2 answers

I added a built-in policy to call the lambda:

 { "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1474873816000", "Effect": "Allow", "Action": [ "lambda:InvokeFunction" ], "Resource": [ "arn:aws:lambda:ap-southeast-1:178284945954:function:wowauctions_get_auction_data" ] } ] } 

And now it works.

+5
source

As Robo mentioned in the comments, adding Principal -based permission is the easiest way to do this:

 "FooFunctionPermission" : { "Type" : "AWS::Lambda::Permission", "Properties" : { "Action" : "lambda:InvokeFunction", "FunctionName" : { "Ref" : "FooFunction" }, "Principal" : "sns.amazonaws.com" } } 
0
source

All Articles