aws-cdk-lib.aws_lambda_event_sources.SelfManagedKafkaEventSource

class SelfManagedKafkaEventSource

LanguageType name
.NETAmazon.CDK.AWS.Lambda.EventSources.SelfManagedKafkaEventSource
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awslambdaeventsources#SelfManagedKafkaEventSource
Javasoftware.amazon.awscdk.services.lambda.eventsources.SelfManagedKafkaEventSource
Pythonaws_cdk.aws_lambda_event_sources.SelfManagedKafkaEventSource
TypeScript (source)aws-cdk-lib » aws_lambda_event_sources » SelfManagedKafkaEventSource

Implements IEventSource

Extends StreamEventSource

Use a self hosted Kafka installation as a streaming source for AWS Lambda.

Example

import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
import { SelfManagedKafkaEventSource } from 'aws-cdk-lib/aws-lambda-event-sources';

// The list of Kafka brokers
const bootstrapServers = ['kafka-broker:9092'];

// The Kafka topic you want to subscribe to
const topic = 'some-cool-topic';

// The secret that allows access to your self hosted Kafka cluster
declare const secret: Secret;

// (Optional) The consumer group id to use when connecting to the Kafka broker. If omitted the UUID of the event source mapping will be used.
const consumerGroupId = "my-consumer-group-id";

declare const myFunction: lambda.Function;
myFunction.addEventSource(new SelfManagedKafkaEventSource({
  bootstrapServers: bootstrapServers,
  topic: topic,
  consumerGroupId: consumerGroupId,
  secret: secret,
  batchSize: 100, // default
  startingPosition: lambda.StartingPosition.TRIM_HORIZON,
}));

Initializer

new SelfManagedKafkaEventSource(props: SelfManagedKafkaEventSourceProps)

Parameters

  • props SelfManagedKafkaEventSourceProps

Methods

NameDescription
bind(target)Called by lambda.addEventSource to allow the event source to bind to this function.

bind(target)

public bind(target: IFunction): void

Parameters

  • target IFunction

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