class SubscriptionFilter
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.SNS.SubscriptionFilter |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awssns#SubscriptionFilter |
Java | software.amazon.awscdk.services.sns.SubscriptionFilter |
Python | aws_cdk.aws_sns.SubscriptionFilter |
TypeScript (source) | aws-cdk-lib » aws_sns » SubscriptionFilter |
A subscription filter for an attribute.
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'],
matchSuffixes: ['ue'],
}),
size: sns.SubscriptionFilter.stringFilter({
denylist: ['small', 'medium'],
}),
price: sns.SubscriptionFilter.numericFilter({
between: { start: 100, stop: 200 },
greaterThan: 300,
}),
store: sns.SubscriptionFilter.existsFilter(),
},
}));
Initializer
new SubscriptionFilter(conditions?: any[])
Parameters
- conditions
any[]
— conditions that specify the message attributes that should be included, excluded, matched, etc.
Properties
Name | Type | Description |
---|---|---|
conditions | any[] | conditions that specify the message attributes that should be included, excluded, matched, etc. |
conditions
Type:
any[]
conditions that specify the message attributes that should be included, excluded, matched, etc.
Methods
Name | Description |
---|---|
static exists | Returns a subscription filter for attribute key matching. |
static numeric | Returns a subscription filter for a numeric attribute. |
static string | Returns a subscription filter for a string attribute. |
Filter()
static existspublic static existsFilter(): SubscriptionFilter
Returns
Returns a subscription filter for attribute key matching.
Filter(numericConditions)
static numericpublic static numericFilter(numericConditions: NumericConditions): SubscriptionFilter
Parameters
- numericConditions
Numeric
Conditions
Returns
Returns a subscription filter for a numeric attribute.
Filter(stringConditions)
static stringpublic static stringFilter(stringConditions: StringConditions): SubscriptionFilter
Parameters
- stringConditions
String
Conditions
Returns
Returns a subscription filter for a string attribute.