EventSourceMappingProps

class aws_cdk.aws_lambda.EventSourceMappingProps(*, batch_size=None, bisect_batch_on_error=None, enabled=None, event_source_arn=None, kafka_bootstrap_servers=None, kafka_topic=None, max_batching_window=None, max_record_age=None, on_failure=None, parallelization_factor=None, retry_attempts=None, source_access_configurations=None, starting_position=None, tumbling_window=None, target)

Bases: aws_cdk.aws_lambda.EventSourceMappingOptions

Properties for declaring a new event source mapping.

Parameters
  • 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 10000. Default: - Amazon Kinesis, Amazon DynamoDB, and Amazon MSK is 100 records. Both the default and maximum for Amazon SQS are 10 messages.

  • bisect_batch_on_error (Optional[bool]) – If the function returns an error, split the batch in two and retry. Default: false

  • enabled (Optional[bool]) – Set to false to disable the event source upon creation. Default: true

  • event_source_arn (Optional[str]) – The Amazon Resource Name (ARN) of the event source. Any record added to this stream can invoke the Lambda function. Default: - not set if using a self managed Kafka cluster, throws an error otherwise

  • kafka_bootstrap_servers (Optional[Sequence[str]]) – A list of host and port pairs that are the addresses of the Kafka brokers in a self managed “bootstrap” Kafka cluster that a Kafka client connects to initially to bootstrap itself. They are in the format abc.example.com:9096. Default: - none

  • kafka_topic (Optional[str]) – The name of the Kafka topic. Default: - no topic

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

  • max_record_age (Optional[Duration]) – The maximum age of a record that Lambda sends to a function for processing. Valid Range: - Minimum value of 60 seconds - Maximum value of 7 days Default: - infinite or until the record expires.

  • on_failure (Optional[IEventSourceDlq]) – An Amazon SQS queue or Amazon SNS topic destination for discarded records. Default: discarded records are ignored

  • parallelization_factor (Union[int, float, None]) – The number of batches to process from each shard concurrently. Valid Range: - Minimum value of 1 - Maximum value of 10 Default: 1

  • retry_attempts (Union[int, float, None]) – The maximum number of times to retry when the function returns an error. Set to undefined if you want lambda to keep retrying infinitely or until the record expires. Valid Range: - Minimum value of 0 - Maximum value of 10000 Default: - infinite or until the record expires.

  • source_access_configurations (Optional[Sequence[SourceAccessConfiguration]]) – Specific settings like the authentication protocol or the VPC components to secure access to your event source. Default: - none

  • starting_position (Optional[StartingPosition]) – The position in the DynamoDB, Kinesis or MSK stream where AWS Lambda should start reading. Default: - Required for Amazon Kinesis, Amazon DynamoDB, and Amazon MSK Streams sources.

  • tumbling_window (Optional[Duration]) – The size of the tumbling windows to group records sent to DynamoDB or Kinesis. Default: - None

  • target (IFunction) – The target AWS Lambda function.

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 10000.

Default

  • Amazon Kinesis, Amazon DynamoDB, and Amazon MSK is 100 records.

Both the default and maximum for Amazon SQS are 10 messages.

Return type

Union[int, float, None]

bisect_batch_on_error

If the function returns an error, split the batch in two and retry.

Default

false

Return type

Optional[bool]

enabled

Set to false to disable the event source upon creation.

Default

true

Return type

Optional[bool]

event_source_arn

The Amazon Resource Name (ARN) of the event source.

Any record added to this stream can invoke the Lambda function.

Default
  • not set if using a self managed Kafka cluster, throws an error otherwise

Return type

Optional[str]

kafka_bootstrap_servers

A list of host and port pairs that are the addresses of the Kafka brokers in a self managed “bootstrap” Kafka cluster that a Kafka client connects to initially to bootstrap itself.

They are in the format abc.example.com:9096.

Default
  • none

Return type

Optional[List[str]]

kafka_topic

The name of the Kafka topic.

Default
  • no topic

Return type

Optional[str]

max_batching_window

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

Maximum of Duration.minutes(5)

Default

Duration.seconds(0)

Return type

Optional[Duration]

max_record_age

The maximum age of a record that Lambda sends to a function for processing.

Valid Range:

  • Minimum value of 60 seconds

  • Maximum value of 7 days

Default
  • infinite or until the record expires.

Return type

Optional[Duration]

on_failure

An Amazon SQS queue or Amazon SNS topic destination for discarded records.

Default

discarded records are ignored

Return type

Optional[IEventSourceDlq]

parallelization_factor

The number of batches to process from each shard concurrently.

Valid Range:

  • Minimum value of 1

  • Maximum value of 10

Default

1

Return type

Union[int, float, None]

retry_attempts

The maximum number of times to retry when the function returns an error.

Set to undefined if you want lambda to keep retrying infinitely or until the record expires.

Valid Range:

  • Minimum value of 0

  • Maximum value of 10000

Default
  • infinite or until the record expires.

Return type

Union[int, float, None]

source_access_configurations

Specific settings like the authentication protocol or the VPC components to secure access to your event source.

Default
  • none

See

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-sourceaccessconfiguration.html

Return type

Optional[List[SourceAccessConfiguration]]

starting_position

The position in the DynamoDB, Kinesis or MSK stream where AWS Lambda should start reading.

Default
  • Required for Amazon Kinesis, Amazon DynamoDB, and Amazon MSK Streams sources.

See

https://docs.aws.amazon.com/kinesis/latest/APIReference/API_GetShardIterator.html#Kinesis-GetShardIterator-request-ShardIteratorType

Return type

Optional[StartingPosition]

target

The target AWS Lambda function.

Return type

IFunction

tumbling_window

The size of the tumbling windows to group records sent to DynamoDB or Kinesis.

Default
  • None

See

https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-windows

Valid Range: 0 - 15 minutes

Return type

Optional[Duration]