aws-cdk-lib.aws_lambda_event_sources.DynamoEventSourceProps

interface DynamoEventSourceProps

LanguageType name
.NETAmazon.CDK.AWS.Lambda.EventSources.DynamoEventSourceProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awslambdaeventsources#DynamoEventSourceProps
Javasoftware.amazon.awscdk.services.lambda.eventsources.DynamoEventSourceProps
Pythonaws_cdk.aws_lambda_event_sources.DynamoEventSourceProps
TypeScript (source)aws-cdk-lib » aws_lambda_event_sources » DynamoEventSourceProps

Example

import * as eventsources from 'aws-cdk-lib/aws-lambda-event-sources';
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';

declare const fn: lambda.Function;
const table = new dynamodb.Table(this, 'Table', {
  partitionKey: {
    name: 'id',
    type: dynamodb.AttributeType.STRING,
  },
  stream: dynamodb.StreamViewType.NEW_IMAGE,
});
fn.addEventSource(new eventsources.DynamoEventSource(table, {
  startingPosition: lambda.StartingPosition.LATEST,
  filters: [lambda.FilterCriteria.filter({ eventName: lambda.FilterRule.isEqual('INSERT') })],
}));

Properties

NameTypeDescription
startingPositionStartingPositionWhere to begin consuming the stream.
batchSize?numberThe largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
bisectBatchOnError?booleanIf the function returns an error, split the batch in two and retry.
enabled?booleanIf the stream event source mapping should be enabled.
filters?{ [string]: any }[]Add filter criteria option.
maxBatchingWindow?DurationThe maximum amount of time to gather records before invoking the function.
maxRecordAge?DurationThe maximum age of a record that Lambda sends to a function for processing.
onFailure?IEventSourceDlqAn Amazon SQS queue or Amazon SNS topic destination for discarded records.
parallelizationFactor?numberThe number of batches to process from each shard concurrently.
reportBatchItemFailures?booleanAllow functions to return partially successful responses for a batch of records.
retryAttempts?numberMaximum number of retry attempts Valid Range: * Minimum value of 0 * Maximum value of 10000.
tumblingWindow?DurationThe size of the tumbling windows to group records sent to DynamoDB or Kinesis Valid Range: 0 - 15 minutes.

startingPosition

Type: StartingPosition

Where to begin consuming the stream.


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 and SelfManagedKafkaEventSource

bisectBatchOnError?

Type: boolean (optional, default: false)

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


enabled?

Type: boolean (optional, default: true)

If the stream event source mapping should be enabled.


filters?

Type: { [string]: any }[] (optional, default: None)

Add filter criteria option.


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

See also: https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventsourcemapping.html#invocation-eventsourcemapping-batching


maxRecordAge?

Type: Duration (optional, default: the retention period configured on the stream)

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

onFailure?

Type: IEventSourceDlq (optional, default: discarded records are ignored)

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


parallelizationFactor?

Type: number (optional, default: 1)

The number of batches to process from each shard concurrently.

Valid Range:

  • Minimum value of 1
  • Maximum value of 10

reportBatchItemFailures?

Type: boolean (optional, default: false)

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

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


retryAttempts?

Type: number (optional, default: retry until the record expires)

Maximum number of retry attempts Valid Range: * Minimum value of 0 * Maximum value of 10000.


tumblingWindow?

Type: Duration (optional, default: None)

The size of the tumbling windows to group records sent to DynamoDB or Kinesis Valid Range: 0 - 15 minutes.