Class ManagedKafkaEventSource

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.lambda.eventsources.StreamEventSource
software.amazon.awscdk.services.lambda.eventsources.ManagedKafkaEventSource
All Implemented Interfaces:
IEventSource, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.96.0 (build 921e240)", date="2024-04-10T22:22:30.107Z") @Stability(Stable) public class ManagedKafkaEventSource extends StreamEventSource
Use a MSK cluster as a streaming source for AWS Lambda.

Example:

 import software.amazon.awscdk.services.secretsmanager.Secret;
 import software.amazon.awscdk.services.lambda.eventsources.ManagedKafkaEventSource;
 Function myFunction;
 // Your MSK cluster arn
 String clusterArn = "arn:aws:kafka:us-east-1:0123456789019:cluster/SalesCluster/abcd1234-abcd-cafe-abab-9876543210ab-4";
 // The Kafka topic you want to subscribe to
 String topic = "some-cool-topic";
 // The secret that allows access to your MSK cluster
 // You still have to make sure that it is associated with your cluster as described in the documentation
 Secret secret = Secret.Builder.create(this, "Secret").secretName("AmazonMSK_KafkaSecret").build();
 myFunction.addEventSource(ManagedKafkaEventSource.Builder.create()
         .clusterArn(clusterArn)
         .topic(topic)
         .secret(secret)
         .batchSize(100) // default
         .startingPosition(StartingPosition.TRIM_HORIZON)
         .build());
 
  • Constructor Details

    • ManagedKafkaEventSource

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

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

      @Stability(Stable) public ManagedKafkaEventSource(@NotNull ManagedKafkaEventSourceProps props)
      Parameters:
      props - This parameter is required.
  • Method Details

    • bind

      @Stability(Stable) public void bind(@NotNull IFunction target)
      Called by lambda.addEventSource to allow the event source to bind to this function.

      Specified by:
      bind in interface IEventSource
      Specified by:
      bind in class StreamEventSource
      Parameters:
      target - This parameter is required.
    • getEventSourceMappingArn

      @Stability(Stable) @NotNull public String getEventSourceMappingArn()
      The ARN for this EventSourceMapping.
    • getEventSourceMappingId

      @Stability(Stable) @NotNull public String getEventSourceMappingId()
      The identifier for this EventSourceMapping.