class ManagedKafkaEventSource
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Lambda.EventSources.ManagedKafkaEventSource |
Java | software.amazon.awscdk.services.lambda.eventsources.ManagedKafkaEventSource |
Python | aws_cdk.aws_lambda_event_sources.ManagedKafkaEventSource |
TypeScript (source) | @aws-cdk/aws-lambda-event-sources » ManagedKafkaEventSource |
Implements
IEvent
Extends
Stream
Use a MSK cluster as a streaming source for AWS Lambda.
Example
import { Secret } from '@aws-cdk/aws-secretsmanager';
import { ManagedKafkaEventSource } from '@aws-cdk/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
Properties
Name | Type | Description |
---|---|---|
event | string | The identifier for this EventSourceMapping. |
eventSourceMappingId
Type:
string
The identifier for this EventSourceMapping.
Methods
Name | Description |
---|---|
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.