FilterOrPolicy

class aws_cdk.aws_sns.FilterOrPolicy

Bases: object

Class for building the FilterPolicy by avoiding union types.

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 message body:
# color: 'red' or 'orange'
my_topic.add_subscription(subscriptions.LambdaSubscription(fn,
    filter_policy_with_message_body={
        "background": sns.FilterOrPolicy.policy({
            "color": sns.FilterOrPolicy.filter(sns.SubscriptionFilter.string_filter(
                allowlist=["red", "orange"]
            ))
        })
    }
))

Methods

is_filter()

Check if instance is Filter type.

Return type:

bool

is_policy()

Check if instance is Policy type.

Return type:

bool

Attributes

type

Type switch for disambiguating between subclasses.

Static Methods

classmethod filter(filter)

Filter of MessageBody.

Parameters:

filter (SubscriptionFilter) –

Return type:

Filter

classmethod policy(policy)

Policy of MessageBody.

Parameters:

policy (Mapping[str, FilterOrPolicy]) –

Return type:

Policy