aws-cdk-lib.aws_lambda.StartingPosition

enum StartingPosition

LanguageType name
.NETAmazon.CDK.AWS.Lambda.StartingPosition
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awslambda#StartingPosition
Javasoftware.amazon.awscdk.services.lambda.StartingPosition
Pythonaws_cdk.aws_lambda.StartingPosition
TypeScript (source)aws-cdk-lib » aws_lambda » StartingPosition

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

Example

import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
import { DynamoEventSource, SqsDlq } from 'aws-cdk-lib/aws-lambda-event-sources';

declare const table: dynamodb.Table;

const deadLetterQueue = new sqs.Queue(this, 'deadLetterQueue');

declare const fn: lambda.Function;
fn.addEventSource(new DynamoEventSource(table, {
  startingPosition: lambda.StartingPosition.TRIM_HORIZON,
  batchSize: 5,
  bisectBatchOnError: true,
  onFailure: new SqsDlq(deadLetterQueue),
  retryAttempts: 10,
}));

Members

NameDescription
TRIM_HORIZONStart reading at the last untrimmed record in the shard in the system, which is the oldest data record in the shard.
LATESTStart reading just after the most recent record in the shard, so that you always read the most recent data in the shard.
AT_TIMESTAMPStart reading from a position defined by a time stamp.

TRIM_HORIZON

Start reading at the last untrimmed record in the shard in the system, which is the oldest data record in the shard.


LATEST

Start reading just after the most recent record in the shard, so that you always read the most recent data in the shard.


AT_TIMESTAMP

Start reading from a position defined by a time stamp.

Only supported for Amazon Kinesis streams, otherwise an error will occur. If supplied, startingPositionTimestamp must also be set.