Skip to content
v2.273.0

StringConditions Struct ​

Conditions that can be applied to string attributes.

Example ​

ts
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'],
      matchSuffixes: ['ue'],
    }),
    size: sns.SubscriptionFilter.stringFilter({
      denylist: ['small', 'medium'],
    }),
    price: sns.SubscriptionFilter.numericFilter({
      between: { start: 100, stop: 200 },
      greaterThan: 300,
    }),
    store: sns.SubscriptionFilter.existsFilter(),
  },
}));

Properties ​

allowliststring[]allowlisttyping.List[str]allowlistList<String>Allowliststring[]Allowlist*[]*string= None#
Match one or more values.
denyliststring[]denylisttyping.List[str]denylistList<String>Denyliststring[]Denylist*[]*string= None#
Match any value that doesn't include any of the specified values.
matchPrefixesstring[]match_prefixestyping.List[str]matchPrefixesList<String>MatchPrefixesstring[]MatchPrefixes*[]*string= None#
Matches values that begins with the specified prefixes.
matchSuffixesstring[]match_suffixestyping.List[str]matchSuffixesList<String>MatchSuffixesstring[]MatchSuffixes*[]*string= None#
Matches values that end with the specified suffixes.