SqsDlq Class
An SQS dead letter queue destination configuration for a Lambda event source.
Example
ts
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,
}));
python
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
))
java
import software.amazon.awscdk.services.dynamodb.*;
import software.amazon.awscdk.services.lambda.eventsources.DynamoEventSource;
import software.amazon.awscdk.services.lambda.eventsources.SqsDlq;
Table table;
Function fn;
Queue deadLetterQueue = new Queue(this, "deadLetterQueue");
fn.addEventSource(DynamoEventSource.Builder.create(table)
.startingPosition(StartingPosition.TRIM_HORIZON)
.batchSize(5)
.bisectBatchOnError(true)
.onFailure(new SqsDlq(deadLetterQueue))
.retryAttempts(10)
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.DynamoDB;
using Amazon.CDK.AWS.Lambda.EventSources;
Table table;
Function fn;
var deadLetterQueue = new Queue(this, "deadLetterQueue");
fn.AddEventSource(new DynamoEventSource(table, new DynamoEventSourceProps {
StartingPosition = StartingPosition.TRIM_HORIZON,
BatchSize = 5,
BisectBatchOnError = true,
OnFailure = new SqsDlq(deadLetterQueue),
RetryAttempts = 10
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import dynamodb "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
var table Table
var fn Function
deadLetterQueue := sqs.NewQueue(this, jsii.String("deadLetterQueue"))
fn.AddEventSource(awscdk.NewDynamoEventSource(table, &DynamoEventSourceProps{
StartingPosition: lambda.StartingPosition_TRIM_HORIZON,
BatchSize: jsii.Number(5),
BisectBatchOnError: jsii.Boolean(true),
OnFailure: awscdk.NewSqsDlq(deadLetterQueue),
RetryAttempts: jsii.Number(10),
}))
Initializer
Methods
bind(_target: IEventSourceMapping, targetHandler: IFunction): DlqDestinationConfigdef bind(self, _target: IEventSourceMapping, target_handler: IFunction) -> DlqDestinationConfigpublic DlqDestinationConfig bind(IEventSourceMapping _target, IFunction targetHandler)public DlqDestinationConfig Bind(IEventSourceMapping _target, IFunction targetHandler)func Bind(_target IEventSourceMapping, TargetHandler IFunction) DlqDestinationConfig#Returns a destination configuration for the DLQ.