Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aws-events] Add support for Rule Dead Letter Queue #11612

Assignees
Labels
@aws-cdk/aws-events Related to CloudWatch Events effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. in-progress This issue is being actively worked on. p1

Comments

@DaWyz
Copy link
Contributor

DaWyz commented Nov 21, 2020

Amazon EventBridge recently added support for dead letter queues.

Use Case

It makes event-driven applications more resilient and durable by storing your events in queues when the events can't be delivered, or the target is unavailable. See the documentation for more information.

Proposed Solution

Following the CloudFormation documentation, it is possible to pass the deadLetterConfig at the rule level and at the target level. I suspect it makes more sense to set it at the target level so we can target different DLQs for targets on the same rule if needed.

A target would have the possibility to pass a Queue as a property. That would be straight forward. Also, we would need to attach a policy to the queue to allow the rule to SendMessage to the queue.

See below a usage example.

import * as logs from "@aws-cdk/aws-logs";
import * as sqs from "@aws-cdk/aws-sqs";
import * as events from "@aws-cdk/aws-events";
import * as targets from "@aws-cdk/aws-events-targets";

const logGroup = new logs.LogGroup(this, 'MyLogGroup', {
  logGroupName: 'MyLogGroup',
});

const rule = new events.Rule(this, 'rule', {
  eventPattern: {
    source: ["aws.ec2"],
  },
});

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

rule.addTarget(new targets.CloudWatchLogGroup(logGroup, {
  deadLetterQueue: myDeadLetterQueue
}));

Others

I'm happy to have a go at it.

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@DaWyz DaWyz added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 21, 2020
@github-actions github-actions bot added the @aws-cdk/aws-events Related to CloudWatch Events label Nov 21, 2020
@DaWyz
Copy link
Contributor Author

DaWyz commented Nov 22, 2020

Added a Draft Pull Request for an idea of the implementation. It's only for the Lambda function. I guess we could move the code to the util file if needed, then add the property/call to the function in each targets (or create a BaseTarget class ?). Happy to only work on one of the targets on this pull request.

@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Nov 23, 2020
@shivlaks shivlaks added p1 effort/medium Medium work item – several days of effort labels Dec 1, 2020
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Dec 7, 2020
@NGL321 NGL321 assigned rix0rrr and unassigned shivlaks Jan 25, 2021
@mergify mergify bot closed this as completed in #11617 Mar 3, 2021
mergify bot pushed a commit that referenced this issue Mar 3, 2021
Add DLQ Configuration to Rule targets. Using a DLQ on a rule prevents the application to loose events after all retry attempts are exhausted.

Resolves #11612 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Mar 3, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

cornerwings pushed a commit to cornerwings/aws-cdk that referenced this issue Mar 8, 2021
Add DLQ Configuration to Rule targets. Using a DLQ on a rule prevents the application to loose events after all retry attempts are exhausted.

Resolves aws#11612 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment