LambdaSubscriptionProps

class aws_cdk.aws_sns_subscriptions.LambdaSubscriptionProps(*, dead_letter_queue=None, filter_policy=None, filter_policy_with_message_body=None)

Bases: SubscriptionProps

Properties for a Lambda subscription.

Parameters:
  • dead_letter_queue (Optional[IQueue]) – Queue to be used as dead letter queue. If not passed no dead letter queue is enabled. Default: - No dead letter queue enabled.

  • filter_policy (Optional[Mapping[str, SubscriptionFilter]]) – The filter policy. Default: - all messages are delivered

  • filter_policy_with_message_body (Optional[Mapping[str, FilterOrPolicy]]) – 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. Default: - all messages are delivered

ExampleMetadata:

infused

Example:

import aws_cdk.aws_lambda as lambda_
# fn: lambda.Function


my_topic = sns.Topic(self, "MyTopic")

# 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
my_topic.add_subscription(subscriptions.LambdaSubscription(fn,
    filter_policy={
        "color": sns.SubscriptionFilter.string_filter(
            allowlist=["red", "orange"],
            match_prefixes=["bl"],
            match_suffixes=["ue"]
        ),
        "size": sns.SubscriptionFilter.string_filter(
            denylist=["small", "medium"]
        ),
        "price": sns.SubscriptionFilter.numeric_filter(
            between=sns.BetweenCondition(start=100, stop=200),
            greater_than=300
        ),
        "store": sns.SubscriptionFilter.exists_filter()
    }
))

Attributes

dead_letter_queue

Queue to be used as dead letter queue.

If not passed no dead letter queue is enabled.

Default:
  • No dead letter queue enabled.

filter_policy

The filter policy.

Default:
  • all messages are delivered

filter_policy_with_message_body

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.

Default:
  • all messages are delivered