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

events-targets: dead letter queue for an ECS task target #21118

Closed
2 tasks
gregwebs opened this issue Jul 13, 2022 · 1 comment · Fixed by #21396
Closed
2 tasks

events-targets: dead letter queue for an ECS task target #21118

gregwebs opened this issue Jul 13, 2022 · 1 comment · Fixed by #21396
Labels
@aws-cdk/aws-events-targets effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1

Comments

@gregwebs
Copy link

gregwebs commented Jul 13, 2022

Describe the feature

For an Event Bridge rule with an ECS task target, support a dead letter queue.

Use Case

This has been implemented for other targets already such as Lambda. It may be useful to track problems with invoking the task.

Proposed Solution

workaround based on the pattern of this PR.
I tested that this produces a dead letter queue in the event bridge rule target.

import * as events from '@aws-cdk/aws-events';
import * as events_targets from '@aws-cdk/aws-events-targets';
import * as sqs from '@aws-cdk/aws-sqs';

interface EcsTaskProps extends events_targets.EcsTaskProps {
    deadLetterQueue?: sqs.Queue;
}

class EcsTask implements events.IRuleTarget {
    readonly deadLetterQueue?: sqs.Queue;
    readonly wrappedTask: events_targets.EcsTask
    constructor(private readonly props: EcsTaskProps) {
        this.deadLetterQueue = props.deadLetterQueue ;
        this.wrappedTask = new events_targets.EcsTask(props);
    }

    public bind(rule: events.IRule, _id?: string): events.RuleTargetConfig {
        const wrappedResult = this.wrappedTask.bind(rule, _id);
        let deadLetterConfig: events.CfnRule.DeadLetterConfigProperty | undefined = undefined
        if (this.deadLetterQueue) {
            events_targets.addToDeadLetterQueueResourcePolicy(rule, this.deadLetterQueue);
            deadLetterConfig = this.deadLetterQueue ? { arn: this.deadLetterQueue?.queueArn } : undefined
        }
        return { ...wrappedResult, deadLetterConfig }
    }
}

Other Information

No response

Acknowledgements

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

CDK version used

2

Environment details (OS name and version, etc.)

Mac

@gregwebs gregwebs added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 13, 2022
@gregwebs gregwebs changed the title (module name): (short issue description) events-targets: dead letter queue for an ECS task target Jul 13, 2022
@rix0rrr rix0rrr added effort/small Small work item – less than a day of effort p1 and removed needs-triage This issue or PR still needs to be triaged. labels Jul 25, 2022
@rix0rrr rix0rrr removed their assignment Jul 25, 2022
@mergify mergify bot closed this as completed in #21396 Aug 1, 2022
mergify bot pushed a commit that referenced this issue Aug 1, 2022
Add DLQ support for ECS target.

Closes #21118.

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [X] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [X] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*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 Aug 1, 2022

⚠️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.

josephedward pushed a commit to josephedward/aws-cdk that referenced this issue Aug 30, 2022
Add DLQ support for ECS target.

Closes aws#21118.

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [X] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [X] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*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
Labels
@aws-cdk/aws-events-targets effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants