SnsEventSource

class aws_cdk.aws_lambda_event_sources.SnsEventSource(topic, *, dead_letter_queue=None, filter_policy=None, filter_policy_with_message_body=None)

Bases: object

Use an Amazon SNS topic as an event source for AWS Lambda.

ExampleMetadata:

infused

Example:

import aws_cdk.aws_sns as sns
from aws_cdk.aws_lambda_event_sources import SnsEventSource

# topic: sns.Topic

# fn: lambda.Function

dead_letter_queue = sqs.Queue(self, "deadLetterQueue")
fn.add_event_source(SnsEventSource(topic,
    filter_policy={},
    dead_letter_queue=dead_letter_queue
))
Parameters:
  • topic (ITopic) –

  • 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 delivered

  • filter_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, use filterPolicy. A maximum of one of filterPolicyWithMessageBody and filterPolicy may be used. Default: - all messages are delivered

Methods

bind(target)

Called by lambda.addEventSource to allow the event source to bind to this function.

Parameters:

target (IFunction) –

Return type:

None

Attributes

topic