Open2
AWS SNSからLambda連携をCDKで
import * as sns from '@aws-cdk/aws-sns';
import { SnsEventSource } from '@aws-cdk/aws-lambda-event-sources';
const topic = new sns.Topic(...);
const deadLetterQueue = new sqs.Queue(this, 'deadLetterQueue');
lambda.addEventSource(new SnsEventSource(topic, {
filterPolicy: { ... },
deadLetterQueue: deadLetterQueue
}));
lambda側ではevent.Records[0].Sns.Messageで受け取れる