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.84.0 (build 5404dcf)", date="2023-06-19T16:30:41.453Z") @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 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(LambdaSubscription.Builder.create(fn)
         .filterPolicy(Map.of(
                 "color", SubscriptionFilter.stringFilter(StringConditions.builder()
                         .allowlist(List.of("red", "orange"))
                         .matchPrefixes(List.of("bl"))
                         .build()),
                 "size", SubscriptionFilter.stringFilter(StringConditions.builder()
                         .denylist(List.of("small", "medium"))
                         .build()),
                 "price", SubscriptionFilter.numericFilter(NumericConditions.builder()
                         .between(BetweenCondition.builder().start(100).stop(200).build())
                         .greaterThan(300)
                         .build()),
                 "store", SubscriptionFilter.existsFilter()))
         .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.