class KafkaDlq
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.Lambda.EventSources.KafkaDlq |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awslambdaeventsources#KafkaDlq |
Java | software.amazon.awscdk.services.lambda.eventsources.KafkaDlq |
Python | aws_cdk.aws_lambda_event_sources.KafkaDlq |
TypeScript (source) | aws-cdk-lib » aws_lambda_event_sources » KafkaDlq |
Implements
IEvent
A Kafka topic dead letter queue destination configuration for a Lambda event source.
This destination can only be used with Kafka-based event sources (MSK and self-managed Kafka). When used with other event source types, a validation error will be thrown.
Kafka URI Format
new KafkaDlq('my-topic');
Topic Naming Requirements
Kafka topic names must follow these rules:
- Only alphanumeric characters, dots (.), underscores (_), and hyphens (-) are allowed
- Cannot be empty
- Must be a valid Kafka topic name
Example
import { ManagedKafkaEventSource, KafkaDlq } from 'aws-cdk-lib/aws-lambda-event-sources';
// Your MSK cluster arn
const clusterArn = 'arn:aws:kafka:us-east-1:0123456789019:cluster/SalesCluster/abcd1234-abcd-cafe-abab-9876543210ab-4';
// The Kafka topic you want to subscribe to
const topic = 'some-cool-topic';
declare const myFunction: lambda.Function;
// Create a Kafka DLQ destination
const kafkaDlq = new KafkaDlq('failure-topic');
myFunction.addEventSource(new ManagedKafkaEventSource({
clusterArn,
topic,
startingPosition: lambda.StartingPosition.TRIM_HORIZON,
onFailure: kafkaDlq,
provisionedPollerConfig: {
minimumPollers: 1,
maximumPollers: 1,
},
}));
Initializer
new KafkaDlq(topicName: string)
Parameters
- topicName
string
Creates a new Kafka DLQ destination.
Methods
| Name | Description |
|---|---|
| bind(_target, _targetHandler) | Returns a destination configuration for the DLQ. |
bind(_target, _targetHandler)
public bind(_target: IEventSourceMapping, _targetHandler: IFunction): DlqDestinationConfig
Parameters
- _target
IEventSource Mapping - _targetHandler
IFunction
Returns
Returns a destination configuration for the DLQ.
The returned configuration is used in the AWS Lambda EventSourceMapping's DestinationConfig to specify where failed records should be sent.

.NET
Go
Java
Python
TypeScript (