DynamoEventSourceProps

class aws_cdk.aws_lambda_event_sources.DynamoEventSourceProps(*, starting_position, batch_size=None, enabled=None, max_batching_window=None, bisect_batch_on_error=None, max_record_age=None, on_failure=None, parallelization_factor=None, report_batch_item_failures=None, retry_attempts=None, tumbling_window=None)

Bases: StreamEventSourceProps

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)

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

  • 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: - the retention period configured on the stream

  • 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

  • report_batch_item_failures (Optional[bool]) – Allow functions to return partially successful responses for a batch of records. Default: false

  • retry_attempts (Union[int, float, None]) – Maximum number of retry attempts Valid Range: * Minimum value of 0 * Maximum value of 10000. Default: - retry until the record expires

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

ExampleMetadata:

infused

Example:

import aws_cdk.aws_dynamodb as dynamodb
from aws_cdk.aws_lambda_event_sources import DynamoEventSource, SqsDlq

# table: dynamodb.Table

# fn: lambda.Function


dead_letter_queue = sqs.Queue(self, "deadLetterQueue")
fn.add_event_source(DynamoEventSource(table,
    starting_position=lambda_.StartingPosition.TRIM_HORIZON,
    batch_size=5,
    bisect_batch_on_error=True,
    on_failure=SqsDlq(dead_letter_queue),
    retry_attempts=10
))

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

bisect_batch_on_error

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

Default:

false

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)

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:
  • the retention period configured on the stream

on_failure

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

Default:
  • discarded records are ignored

parallelization_factor

The number of batches to process from each shard concurrently.

Valid Range:

  • Minimum value of 1

  • Maximum value of 10

Default:

1

report_batch_item_failures

Allow functions to return partially successful responses for a batch of records.

Default:

false

See:

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

retry_attempts
  • Minimum value of 0 * Maximum value of 10000.

Default:
  • retry until the record expires

Type:

Maximum number of retry attempts Valid Range

starting_position

Where to begin consuming the stream.

tumbling_window

0 - 15 minutes.

Default:
  • None

Type:

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