aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.55k stars 3.87k forks source link

[aws-events-targets] Add DLQ support for Kinesis Target #31428

Closed ryanschulz46 closed 2 weeks ago

ryanschulz46 commented 2 weeks ago

Describe the feature

This is an available feature through the AWS Console already and is supported in many other target but not Kinesis.

[aws-events] Add support for Rule Dead Letter Queue: https://github.com/aws/aws-cdk/issues/11612 feat(events-targets): Add DLQ support for SQS target: https://github.com/aws/aws-cdk/issues/16417

Use Case

Use aws-cdk-lib/aws-events-targets to create Kinesis Targets, but also support a DLQ for such target

Proposed Solution

Extend aws-cdk-lib/aws-events-targets/kinesis-stream/KinesisStreamProps to extend TargetBaseProps (similar to SQS)

import * as events from 'aws-cdk-lib/aws-events';
import * as event_targets from 'aws-cdk-lib/aws-events-targets';
import * as sqs from 'aws-cdk-lib/aws-sqs';
import * as kinesis from 'aws-cdk-lib/aws-kinesis';

// Create Stream and DLQ
const myKinesisStream = new kinesis.Stream(this, 'MyKinesisStream', {
    streamName: 'my-kinesis-stream',
    streamMode: kinesis.StreamMode.ON_DEMAND,
});
const myDeadLetterQueue = new sqs.Queue(this, 'MyDeadLetterQueue');

// Kinesis Target created with DLQ configured
const myKinesisTarget = new event_targets.KinesisStream(myKinesisStream, {deadLetterQueue: myDeadLetterQueue});

// Example Target Use-case: Connecting EventBus to Kinesis Stream now has DLQ
const myEventBus = new events.EventBus(this, 'MyEventBus', { eventBusName: 'my-event-bus'});

const myEventRule = new events.Rule(this, 'MyEventRule', {
    eventBus: myEventBus,
    eventPattern: ['pattern'],
    targets: [myKinesisTarget],
});

Other Information

No response

Acknowledgements

CDK version used

2.149.0

Environment details (OS name and version, etc.)

AL2

khushail commented 2 weeks ago

Hi @ryanschulz46 , thanks for reaching out with this request. This would be good to have (https://github.com/aws/aws-cdk/pull/13660) Contribution from the community are welcome.

github-actions[bot] commented 2 weeks ago

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

github-actions[bot] commented 2 weeks ago

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.