LambdaSubscription
- class aws_cdk.aws_sns_subscriptions.LambdaSubscription(fn, *, dead_letter_queue=None, filter_policy=None, filter_policy_with_message_body=None)
Bases:
object
Use a Lambda function as a subscription target.
- 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"] )) }) } ))
- Parameters:
fn (
IFunction
) –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 deliveredfilter_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, usefilterPolicy
. A maximum of one offilterPolicyWithMessageBody
andfilterPolicy
may be used. Default: - all messages are delivered
Methods