1
votes

Below are the steps to reproduce using AWS Java API: 1. Create a Nodejs Lambda function 2. Create an SNS topic 3. Subscribe the SNS topic to the lambda function created using it's ARN

Now if we go to the Lambda function and look at the Event Sources tab, we don't see SNS topic listed as an event source. So the SNS doesn't trigger the Lambda function at all. Looks like an AWS issue to me.

P.S: The AWS user keys used to reproduce the above issue had blanket access (Admin Policy) attached. So it doesn't look like a permissions issue. If I repeat the above steps via AWS Console, the event source gets added properly into the Lambda function.

Has anyone encountered this issue before? How to resolve this? Or any workarounds.

1

1 Answers

1
votes

You need to add permission for SNS to call Lambda. You can do this by calling the AddPermission Function.

Background: The Lambda SNS uses the Push Model to invoke Lambda. This means that SNS directly invokes your lambda function (similar to you calling invokeFunction from the Java SDK). The lambda IAM permission model requires that each caller be explicitly permitted to call the function.

This is different from the Lambda Kinesis event source, which uses a Pull Model (the lambda function runs and then pulls records from the Kinesis Stream).