Skip to content
v2.274.0

DynamoEventSourceProps Struct ​

Example ​

ts
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,
  metricsConfig: {
    metrics: [lambda.MetricType.EVENT_COUNT],
  }
}));

Properties ​

batchSizenumberbatch_sizeint | floatbatchSizeNumberBatchSizedoubleBatchSize*float64= 100#
The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
notes

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
bisectBatchOnErrorbooleanbisect_batch_on_errorboolbisectBatchOnErrorBooleanBisectBatchOnErrorboolBisectBatchOnError*bool= false#
If the function returns an error, split the batch in two and retry.
enabledbooleanenabledboolenabledBooleanEnabledboolEnabled*bool= true#
If the stream event source mapping should be enabled.
filterEncryptionIKeyfilter_encryptionIKeyfilterEncryptionIKeyFilterEncryptionIKeyFilterEncryptionIKey= none#
Add Customer managed KMS key to encrypt Filter Criteria.
filters{ [key: string]: any }[]filterstyping.List[typing.Mapping[str, Any]]filtersList<Map<String, Object>>FiltersIDictionary<string, object>[]Filters*[]*map[string]interface{}= None#
Add filter criteria option.
maxBatchingWindowDurationmax_batching_windowDurationmaxBatchingWindowDurationMaxBatchingWindowDurationMaxBatchingWindowDuration#
The maximum amount of time to gather records before invoking the function.

Default: Duration.seconds(0) for Kinesis, DynamoDB, and SQS event sources, Duration.millis(500) for MSK, self-managed Kafka, and Amazon MQ.

Maximum of Duration.minutes(5).

maxRecordAgeDurationmax_record_ageDurationmaxRecordAgeDurationMaxRecordAgeDurationMaxRecordAgeDuration= -1#
The maximum age of a record that Lambda sends to a function for processing.
notes

Valid Range:

  • Minimum value of 60 seconds
  • Maximum value of 7 days

The default value is -1, which sets the maximum age to infinite. When the value is set to infinite, Lambda never discards old records. Record are valid until it expires in the event source.

metricsConfigMetricsConfigmetrics_configMetricsConfigmetricsConfigMetricsConfigMetricsConfigMetricsConfigMetricsConfigMetricsConfig#
Configuration for enhanced monitoring metrics collection When specified, enables collection of additional metrics for the stream event source.

Default: Enhanced monitoring is disabled

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

Default: discarded records are ignored

parallelizationFactornumberparallelization_factorint | floatparallelizationFactorNumberParallelizationFactordoubleParallelizationFactor*float64= 1#
The number of batches to process from each shard concurrently.

Valid Range:

  • Minimum value of 1
  • Maximum value of 10
provisionedPollerConfigProvisionedPollerConfigprovisioned_poller_configProvisionedPollerConfigprovisionedPollerConfigProvisionedPollerConfigProvisionedPollerConfigProvisionedPollerConfigProvisionedPollerConfigProvisionedPollerConfig#
Configuration for provisioned pollers that read from the event source.

Default: no provisioned pollers

When specified, allows control over the minimum and maximum number of pollers that can be provisioned to process events from the source.

reportBatchItemFailuresbooleanreport_batch_item_failuresboolreportBatchItemFailuresBooleanReportBatchItemFailuresboolReportBatchItemFailures*bool= false#
Allow functions to return partially successful responses for a batch of records.
retryAttemptsnumberretry_attemptsint | floatretryAttemptsNumberRetryAttemptsdoubleRetryAttempts*float64#
Maximum number of retry attempts.

Default: -1 (infinite retries)

Set to -1 for infinite retries (until the record expires in the event source).

Valid Range: -1 (infinite) or 0 to 10000

startingPositionStartingPositionstarting_positionStartingPositionstartingPositionStartingPositionStartingPositionStartingPositionStartingPositionStartingPositionrequired#
Where to begin consuming the stream.
tumblingWindowDurationtumbling_windowDurationtumblingWindowDurationTumblingWindowDurationTumblingWindowDuration= None#
The size of the tumbling windows to group records sent to DynamoDB or Kinesis Valid Range: 0 - 15 minutes.