Class LambdaSubscription

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.sns.subscriptions.LambdaSubscription
All Implemented Interfaces:
ITopicSubscription, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)", date="2024-09-19T18:12:08.385Z") @Stability(Stable) public class LambdaSubscription extends software.amazon.jsii.JsiiObject implements ITopicSubscription
Use a Lambda function as a subscription target.

Example:

 import software.amazon.awscdk.services.lambda.*;
 Function fn;
 Topic myTopic = new Topic(this, "MyTopic");
 // Lambda should receive only message matching the following conditions on message body:
 // color: 'red' or 'orange'
 myTopic.addSubscription(LambdaSubscription.Builder.create(fn)
         .filterPolicyWithMessageBody(Map.of(
                 "background", FilterOrPolicy.policy(Map.of(
                         "color", FilterOrPolicy.filter(SubscriptionFilter.stringFilter(StringConditions.builder()
                                 .allowlist(List.of("red", "orange"))
                                 .build()))))))
         .build());
 
  • Constructor Details

    • LambdaSubscription

      protected LambdaSubscription(software.amazon.jsii.JsiiObjectRef objRef)
    • LambdaSubscription

      protected LambdaSubscription(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • LambdaSubscription

      @Stability(Stable) public LambdaSubscription(@NotNull IFunction fn, @Nullable LambdaSubscriptionProps props)
      Parameters:
      fn - This parameter is required.
      props -
    • LambdaSubscription

      @Stability(Stable) public LambdaSubscription(@NotNull IFunction fn)
      Parameters:
      fn - This parameter is required.
  • Method Details

    • bind

      @Stability(Stable) @NotNull public TopicSubscriptionConfig bind(@NotNull ITopic topic)
      Returns a configuration for a Lambda function to subscribe to an SNS topic.

      Specified by:
      bind in interface ITopicSubscription
      Parameters:
      topic - This parameter is required.