StringConditions

class aws_cdk.aws_sns.StringConditions(*, allowlist=None, denylist=None, match_prefixes=None, match_suffixes=None)

Bases: object

Conditions that can be applied to string attributes.

Parameters:
  • allowlist (Optional[Sequence[str]]) – Match one or more values. Default: - None

  • denylist (Optional[Sequence[str]]) – Match any value that doesn’t include any of the specified values. Default: - None

  • match_prefixes (Optional[Sequence[str]]) – Matches values that begins with the specified prefixes. Default: - None

  • match_suffixes (Optional[Sequence[str]]) – Matches values that end with the specified suffixes. Default: - None

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

allowlist

Match one or more values.

Default:
  • None

denylist

Match any value that doesn’t include any of the specified values.

Default:
  • None

match_prefixes

Matches values that begins with the specified prefixes.

Default:
  • None

match_suffixes

Matches values that end with the specified suffixes.

Default:
  • None