0
votes

I need to add 'SNS' based trigger to my Lambda function, But create-event-source-mapping — AWS CLI Command Reference says only DynamoDB, Kinesis, SQS.

The aws lambda create-event-source-mapping command for SNS, S3 etc based triggers fails with --event-source-arn:

An error occurred (InvalidParameterValueException) when calling the CreateEventSourceMapping operation: Unrecognized event source, must be kinesis, dynamodb stream or sqs. Unsupported source arn

However these can be accomplished through AWS console.

Any thoughts?

2
What is your actual command which gives the cited error? - Marcin

2 Answers

3
votes

To have a SNS triggers a Lambda, the Lambda need to subscribe the SNS's topic. You can refer to Tutorial: Using AWS Lambda with Amazon Simple Notification Service on getting Lambda triggered when a message published to SNS's topic.

0
votes

*the cdk construct lib links provided are in python but you can use a language or your choice

In order to set a sns trigger on Lambda you have do following things, 1) create a SNS Topic 2) create a Lambda function 3) create a Lambda event source 4) integrate all

You can use AWS CDK to do all this Creating a SNS Topic: https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_sns/Topic.html

Creating a Lambda Function https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_lambda/Function.html

Use functuon_obj.add_ecent_source(SNS_obj) to integrate all.

The IAM permissions to invoke your function on sns event will automatically get handled and you see then under Lambda permissions tab on console.

Do mark the answer right if it helps.