interface ManagedKafkaEventSourceProps
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Lambda.EventSources.ManagedKafkaEventSourceProps |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awslambdaeventsources#ManagedKafkaEventSourceProps |
Java | software.amazon.awscdk.services.lambda.eventsources.ManagedKafkaEventSourceProps |
Python | aws_cdk.aws_lambda_event_sources.ManagedKafkaEventSourceProps |
TypeScript (source) | aws-cdk-lib » aws_lambda_event_sources » ManagedKafkaEventSourceProps |
Properties for a MSK event source.
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,
}));
Properties
Name | Type | Description |
---|---|---|
cluster | string | An MSK cluster construct. |
starting | Starting | Where to begin consuming the stream. |
topic | string | The Kafka topic to subscribe to. |
batch | number | The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function. |
consumer | string | The identifier for the Kafka consumer group to join. |
enabled? | boolean | If the stream event source mapping should be enabled. |
filter | IKey | Add Customer managed KMS key to encrypt Filter Criteria. |
filters? | { [string]: any }[] | Add filter criteria to Event Source. |
max | Duration | The maximum amount of time to gather records before invoking the function. |
on | IEvent | Add an on Failure Destination for this Kafka event. |
secret? | ISecret | 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. |
clusterArn
Type:
string
An MSK cluster construct.
startingPosition
Type:
Starting
Where to begin consuming the stream.
topic
Type:
string
The Kafka topic to subscribe to.
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
andSelfManagedKafkaEventSource
- 1000 for
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.
filterEncryption?
Type:
IKey
(optional, default: none)
Add Customer managed KMS key to encrypt Filter Criteria.
See also: https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-managed-cmk
filters?
Type:
{ [string]: any }[]
(optional, default: none)
Add filter criteria to Event Source.
See also: https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html
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).
onFailure?
Type:
IEvent
(optional, default: discarded records are ignored)
Add an on Failure Destination for this Kafka event.
SNS/SQS/S3 are supported
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.