aws-cdk-lib.aws_lambda_event_sources.ManagedKafkaEventSource

class ManagedKafkaEventSource

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

Implements IEventSource

Extends StreamEventSource

Use a MSK cluster as a streaming source for AWS Lambda.

Example

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

// Your MSK cluster arn
const clusterArn = 'arn:aws:kafka:us-east-1:0123456789019:cluster/SalesCluster/abcd1234-abcd-cafe-abab-9876543210ab-4';

// The Kafka topic you want to subscribe to
const 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
const secret = new Secret(this, 'Secret', { secretName: 'AmazonMSK_KafkaSecret' });

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

Initializer

new ManagedKafkaEventSource(props: ManagedKafkaEventSourceProps)

Parameters

  • props ManagedKafkaEventSourceProps

Properties

NameTypeDescription
eventSourceMappingArnstringThe ARN for this EventSourceMapping.
eventSourceMappingIdstringThe identifier for this EventSourceMapping.

eventSourceMappingArn

Type: string

The ARN for this EventSourceMapping.


eventSourceMappingId

Type: string

The identifier for this EventSourceMapping.

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.