SelfManagedKafkaEventSource
- class aws_cdk.aws_lambda_event_sources.SelfManagedKafkaEventSource(*, bootstrap_servers, authentication_method=None, security_group=None, vpc=None, vpc_subnets=None, topic, secret=None, starting_position, batch_size=None, enabled=None, max_batching_window=None)
Bases:
StreamEventSource
Use a self hosted Kafka installation as a streaming source for AWS Lambda.
- ExampleMetadata:
infused
Example:
from aws_cdk.aws_secretsmanager import Secret from aws_cdk.aws_lambda_event_sources import SelfManagedKafkaEventSource # The secret that allows access to your self hosted Kafka cluster # secret: Secret # my_function: lambda.Function # The list of Kafka brokers bootstrap_servers = ["kafka-broker:9092"] # The Kafka topic you want to subscribe to topic = "some-cool-topic" my_function.add_event_source(SelfManagedKafkaEventSource( bootstrap_servers=bootstrap_servers, topic=topic, secret=secret, batch_size=100, # default starting_position=lambda_.StartingPosition.TRIM_HORIZON ))
- Parameters:
bootstrap_servers (
Sequence
[str
]) – 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 formatabc.xyz.com:xxxx
.authentication_method (
Optional
[AuthenticationMethod
]) – The authentication method for your Kafka cluster. Default: AuthenticationMethod.SASL_SCRAM_512_AUTHsecurity_group (
Optional
[ISecurityGroup
]) – If your Kafka brokers are only reachable via VPC, provide the security group here. Default: - none, required if setting vpcvpc (
Optional
[IVpc
]) – If your Kafka brokers are only reachable via VPC provide the VPC here. Default: nonevpc_subnets (
Union
[SubnetSelection
,Dict
[str
,Any
],None
]) – If your Kafka brokers are only reachable via VPC, provide the subnets selection here. Default: - none, required if setting vpctopic (
str
) – The Kafka topic to subscribe to.secret (
Optional
[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. Default: nonestarting_position (
StartingPosition
) – Where to begin consuming the stream.batch_size (
Union
[int
,float
,None
]) – 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 {@link DynamoEventSource} - 10000 for {@link KinesisEventSource}, {@link ManagedKafkaEventSource} and {@link SelfManagedKafkaEventSource} Default: 100enabled (
Optional
[bool
]) – If the stream event source mapping should be enabled. Default: truemax_batching_window (
Optional
[Duration
]) – The maximum amount of time to gather records before invoking the function. Maximum of Duration.minutes(5) Default: Duration.seconds(0)
Methods