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

feat(sqs): support for permission settings for dead letter source queues #28745

Merged
merged 24 commits into from
Jan 29, 2024

Conversation

badmintoncryer
Copy link
Contributor

@badmintoncryer badmintoncryer commented Jan 17, 2024

This PR allows for the configuration of constraints on source queues that can designate this queue as their dead letter queue.

declare const sourceQueue: sqs.IQueue;

// Only the sourceQueue can specify this queue as the dead-letter queue.
const queue1 = new sqs.Queue(this, 'Queue1', {
  redriveAllowPolicy: {
    sourceQueues: [sourceQueue],
  }
});

// No source queues can specify this queue as the dead-letter queue.
const queue2 = new sqs.Queue(this, 'Queue2', {
  redriveAllowPolicy: {
    redrivePermission: sqs.RedrivePermission.DENY_ALL,
  }
});

Closes #19766.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the admired-contributor [Pilot] contributed between 13-24 PRs to the CDK label Jan 17, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team January 17, 2024 18:32
@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 labels Jan 17, 2024
@badmintoncryer badmintoncryer changed the title feat(sqs): support for permission settings for DLQ source queues feat(sqs): support for permission settings for dead letter source queues Jan 17, 2024
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jan 18, 2024
Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍
I left some notes for minor adjustments.

packages/aws-cdk-lib/aws-sqs/lib/queue.ts Outdated Show resolved Hide resolved
packages/aws-cdk-lib/aws-sqs/README.md Outdated Show resolved Hide resolved
packages/aws-cdk-lib/aws-sqs/lib/queue.ts Outdated Show resolved Hide resolved
packages/aws-cdk-lib/aws-sqs/test/sqs.test.ts Outdated Show resolved Hide resolved
packages/aws-cdk-lib/aws-sqs/lib/queue.ts Outdated Show resolved Hide resolved
packages/aws-cdk-lib/aws-sqs/lib/queue.ts Outdated Show resolved Hide resolved
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jan 18, 2024
@badmintoncryer
Copy link
Contributor Author

badmintoncryer commented Jan 18, 2024

@lpizzinidev Thank you for your review! I addressed your comments.

Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying 👍
The implementation of the deadLetterQueue property is pretty old and I think we should stick to the CloudFormation definition when possible for new props to avoid confusion.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 20, 2024
@badmintoncryer
Copy link
Contributor Author

Thank you for the confirmation. And I understand the policy on naming as well.

const redrivePolicy = props.deadLetterQueue
? {
deadLetterTargetArn: props.deadLetterQueue.queue.queueArn,
maxReceiveCount: props.deadLetterQueue.maxReceiveCount,
}
: undefined;

const redriveAllowPolicy = props.redriveAllowPolicy ? {
Copy link
Contributor

@GavinZZ GavinZZ Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understood this logic from reading the docs trings above, but in general this ternary condition is quite confusing for people who look at this piece of code for the first time. Would be nice to have a comment here explaining it (i.e. when sourcePolicy is provided, default to use allow all permission ...).

Fairly minor change, and I'm happy to approve this PR.

@badmintoncryer
Copy link
Contributor Author

@GavinZZ I've updated comments. Please confirm it again.

@GavinZZ
Copy link
Contributor

GavinZZ commented Jan 28, 2024

Thank you for the contribution! Happy to approve once the CI passes.

@badmintoncryer
Copy link
Contributor Author

@GavinZZ Do you know why the CI has failed?? https://github.com/aws/aws-cdk/actions/runs/7680150613/job/20931832477?pr=28745

This problem seems to have occurred in other PRs as well.

Run ./tools/@aws-cdk/prlint
  env:
    GITHUB_TOKEN: ***
    PR_NUMBER: 
    PR_SHA: 
    REPO_ROOT: /home/runner/work/aws-cdk/aws-cdk
⌛  Fetching PR number [2](https://github.com/aws/aws-cdk/actions/runs/7680150613/job/20931832477?pr=28745#step:4:2)87[4](https://github.com/aws/aws-cdk/actions/runs/7680150613/job/20931832477?pr=28745#step:4:4)[5](https://github.com/aws/aws-cdk/actions/runs/7680150613/job/20931832477?pr=28745#step:4:5)
Error: Bad credentials

@badmintoncryer
Copy link
Contributor Author

@GavinZZ
The above problem seems to be resolved. However, the CodeBuild job status remains 'pending' even though it has finished successfully. How can I resolve it ?

@GavinZZ
Copy link
Contributor

GavinZZ commented Jan 29, 2024

We're actively working on a fix on this issue. Sorry for the inconvenience.

@GavinZZ
Copy link
Contributor

GavinZZ commented Jan 29, 2024

@mergify update

Copy link
Contributor

mergify bot commented Jan 29, 2024

update

✅ Branch has been successfully updated

Copy link
Contributor

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for contributing!

Copy link
Contributor

mergify bot commented Jan 29, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Jan 29, 2024
Copy link
Contributor

mergify bot commented Jan 29, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: af747d4
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 9e21803 into aws:main Jan 29, 2024
9 checks passed
Copy link
Contributor

mergify bot commented Jan 29, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Vandita2020 pushed a commit to Vandita2020/aws-cdk that referenced this pull request Jan 30, 2024
…ues (aws#28745)

This PR allows for the configuration of constraints on source queues that can designate this queue as their dead letter queue.

```ts
declare const sourceQueue: sqs.IQueue;

// Only the sourceQueue can specify this queue as the dead-letter queue.
const queue1 = new sqs.Queue(this, 'Queue1', {
  redriveAllowPolicy: {
    sourceQueues: [sourceQueue],
  }
});

// No source queues can specify this queue as the dead-letter queue.
const queue2 = new sqs.Queue(this, 'Queue2', {
  redriveAllowPolicy: {
    redrivePermission: sqs.RedrivePermission.DENY_ALL,
  }
});
```

Closes aws#19766.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
SankyRed pushed a commit that referenced this pull request Feb 8, 2024
…ues (#28745)

This PR allows for the configuration of constraints on source queues that can designate this queue as their dead letter queue.

```ts
declare const sourceQueue: sqs.IQueue;

// Only the sourceQueue can specify this queue as the dead-letter queue.
const queue1 = new sqs.Queue(this, 'Queue1', {
  redriveAllowPolicy: {
    sourceQueues: [sourceQueue],
  }
});

// No source queues can specify this queue as the dead-letter queue.
const queue2 = new sqs.Queue(this, 'Queue2', {
  redriveAllowPolicy: {
    redrivePermission: sqs.RedrivePermission.DENY_ALL,
  }
});
```

Closes #19766.

----

*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
admired-contributor [Pilot] contributed between 13-24 PRs to the CDK effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add suport for RedriveAllowPolicy in the Queue construct
4 participants