amazon-web-servicesaws-lambdaamazon-sns

AWS SNS ought to trigger my lambda, but does not


I have an AWS lambda function that I created via apex. I've also created a SNS topic and a subscription through terraform.

My topic is: 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 a lambda type and the endpoint is: arn:aws:lambda:ap-southeast-1:178284945954:function:wowauctions_get_auction_data

I've confirmed this is the correct function ARN. Everything seems wired up correctly:

SNS picture

I trigger 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 the message ID but no invocation happens. Why?


Solution

  • I added an inline policy to allow the lambda to be invoked:

    {
        "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 it's now working.