aws-cdk-lib.aws_lambda_event_sources.SelfManagedKafkaEventSourceProps

interface SelfManagedKafkaEventSourceProps

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

Properties for a self managed Kafka cluster event source.

If your Kafka cluster is only reachable via VPC make sure to configure it.

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,
}));

Properties

NameTypeDescription
bootstrapServersstring[]The list of host and port pairs that are the addresses of the Kafka brokers in a "bootstrap" Kafka cluster that a Kafka client connects to initially to bootstrap itself.
startingPositionStartingPositionWhere to begin consuming the stream.
topicstringThe Kafka topic to subscribe to.
authenticationMethod?AuthenticationMethodThe authentication method for your Kafka cluster.
batchSize?numberThe largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
consumerGroupId?stringThe identifier for the Kafka consumer group to join.
enabled?booleanIf the stream event source mapping should be enabled.
maxBatchingWindow?DurationThe maximum amount of time to gather records before invoking the function.
rootCACertificate?ISecretThe secret with the root CA certificate used by your Kafka brokers for TLS encryption This field is required if your Kafka brokers use certificates signed by a private CA.
secret?ISecretThe secret with the Kafka credentials, see https://docs.aws.amazon.com/msk/latest/developerguide/msk-password.html for details This field is required if your Kafka brokers are accessed over the Internet.
securityGroup?ISecurityGroupIf your Kafka brokers are only reachable via VPC, provide the security group here.
vpc?IVpcIf your Kafka brokers are only reachable via VPC provide the VPC here.
vpcSubnets?SubnetSelectionIf your Kafka brokers are only reachable via VPC, provide the subnets selection here.

bootstrapServers

Type: string[]

The list of host and port pairs that are the addresses of the Kafka brokers in a "bootstrap" Kafka cluster that a Kafka client connects to initially to bootstrap itself.

They are in the format abc.xyz.com:xxxx.


startingPosition

Type: StartingPosition

Where to begin consuming the stream.


topic

Type: string

The Kafka topic to subscribe to.


authenticationMethod?

Type: AuthenticationMethod (optional, default: AuthenticationMethod.SASL_SCRAM_512_AUTH)

The authentication method for your Kafka cluster.


batchSize?

Type: number (optional, default: 100)

The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.

Your function receives an event with all the retrieved records.

Valid Range:

  • Minimum value of 1
  • Maximum value of:
    • 1000 for DynamoEventSource
    • 10000 for KinesisEventSource, ManagedKafkaEventSource and SelfManagedKafkaEventSource

consumerGroupId?

Type: string (optional, default: none)

The identifier for the Kafka consumer group to join.

The consumer group ID must be unique among all your Kafka event sources. After creating a Kafka event source mapping with the consumer group ID specified, you cannot update this value. The value must have a lenght between 1 and 200 and full the pattern '[a-zA-Z0-9-/:_+=.@-]'.

See also: https://docs.aws.amazon.com/lambda/latest/dg/with-msk.html#services-msk-consumer-group-id


enabled?

Type: boolean (optional, default: true)

If the stream event source mapping should be enabled.


maxBatchingWindow?

Type: Duration (optional, default: Duration.seconds(0) for Kinesis, DynamoDB, and SQS event sources, Duration.millis(500) for MSK, self-managed Kafka, and Amazon MQ.)

The maximum amount of time to gather records before invoking the function.

Maximum of Duration.minutes(5).

See also: https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventsourcemapping.html#invocation-eventsourcemapping-batching


rootCACertificate?

Type: ISecret (optional, default: none)

The secret with the root CA certificate used by your Kafka brokers for TLS encryption This field is required if your Kafka brokers use certificates signed by a private CA.


secret?

Type: ISecret (optional, default: none)

The secret with the Kafka credentials, see https://docs.aws.amazon.com/msk/latest/developerguide/msk-password.html for details This field is required if your Kafka brokers are accessed over the Internet.


securityGroup?

Type: ISecurityGroup (optional, default: none, required if setting vpc)

If your Kafka brokers are only reachable via VPC, provide the security group here.


vpc?

Type: IVpc (optional, default: none)

If your Kafka brokers are only reachable via VPC provide the VPC here.


vpcSubnets?

Type: SubnetSelection (optional, default: none, required if setting vpc)

If your Kafka brokers are only reachable via VPC, provide the subnets selection here.