aws-cdk-lib.aws_sns_subscriptions.LambdaSubscriptionProps

interface LambdaSubscriptionProps

LanguageType name
.NETAmazon.CDK.AWS.SNS.Subscriptions.LambdaSubscriptionProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awssnssubscriptions#LambdaSubscriptionProps
Javasoftware.amazon.awscdk.services.sns.subscriptions.LambdaSubscriptionProps
Pythonaws_cdk.aws_sns_subscriptions.LambdaSubscriptionProps
TypeScript (source)aws-cdk-lib » aws_sns_subscriptions » LambdaSubscriptionProps

Properties for a Lambda subscription.

Example

import * as lambda from 'aws-cdk-lib/aws-lambda';

const myTopic = new sns.Topic(this, 'MyTopic');
declare const fn: lambda.Function;

// Lambda should receive only message matching the following conditions on attributes:
// color: 'red' or 'orange' or begins with 'bl'
// size: anything but 'small' or 'medium'
// price: between 100 and 200 or greater than 300
// store: attribute must be present
myTopic.addSubscription(new subscriptions.LambdaSubscription(fn, {
  filterPolicy: {
    color: sns.SubscriptionFilter.stringFilter({
      allowlist: ['red', 'orange'],
      matchPrefixes: ['bl'],
    }),
    size: sns.SubscriptionFilter.stringFilter({
      denylist: ['small', 'medium'],
    }),
    price: sns.SubscriptionFilter.numericFilter({
      between: { start: 100, stop: 200 },
      greaterThan: 300,
    }),
    store: sns.SubscriptionFilter.existsFilter(),
  },
}));

Properties

NameTypeDescription
deadLetterQueue?IQueueQueue to be used as dead letter queue.
filterPolicy?{ [string]: SubscriptionFilter }The filter policy.
filterPolicyWithMessageBody?{ [string]: FilterOrPolicy }The filter policy that is applied on the message body.

deadLetterQueue?

Type: IQueue (optional, default: No dead letter queue enabled.)

Queue to be used as dead letter queue.

If not passed no dead letter queue is enabled.


filterPolicy?

Type: { [string]: SubscriptionFilter } (optional, default: all messages are delivered)

The filter policy.


filterPolicyWithMessageBody?

Type: { [string]: FilterOrPolicy } (optional, default: all messages are delivered)

The filter policy that is applied on the message body.

To apply a filter policy to the message attributes, use filterPolicy. A maximum of one of filterPolicyWithMessageBody and filterPolicy may be used.