KafkaEventSourceProps

class aws_cdk.aws_lambda_event_sources.KafkaEventSourceProps(*, starting_position, batch_size=None, enabled=None, max_batching_window=None, topic, secret=None)

Bases: BaseStreamEventSourceProps

Properties for a Kafka event source.

Parameters:
  • starting_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: 100

  • enabled (Optional[bool]) – If the stream event source mapping should be enabled. Default: true

  • max_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)

  • topic (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: none

ExampleMetadata:

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_lambda as lambda_
import aws_cdk.aws_lambda_event_sources as lambda_event_sources
import aws_cdk.aws_secretsmanager as secretsmanager
import aws_cdk.core as cdk

# secret: secretsmanager.Secret

kafka_event_source_props = lambda_event_sources.KafkaEventSourceProps(
    starting_position=lambda_.StartingPosition.TRIM_HORIZON,
    topic="topic",

    # the properties below are optional
    batch_size=123,
    enabled=False,
    max_batching_window=cdk.Duration.minutes(30),
    secret=secret
)

Attributes

batch_size

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:

100

enabled

If the stream event source mapping should be enabled.

Default:

true

max_batching_window

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

Maximum of Duration.minutes(5)

Default:

Duration.seconds(0)

secret

//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:

none

Type:

The secret with the Kafka credentials, see https

starting_position

Where to begin consuming the stream.

topic

The Kafka topic to subscribe to.