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

fix(sqs): redrivePermission is set to byQueue no matter what value is specified #29130

Merged
merged 5 commits into from
Mar 1, 2024

Conversation

yoshi-d-24
Copy link
Contributor

@yoshi-d-24 yoshi-d-24 commented Feb 16, 2024

Issue #29129

Closes #29129.

Reason for this change

When redriveAllowPolicy.redrivePermission is specified, any value will be output to template as byQueue

Description of changes

  1. Fix the evaluation order by enclosing the ternary operators in parentheses
         ?? (props.redriveAllowPolicy.sourceQueues ? RedrivePermission.BY_QUEUE : RedrivePermission.ALLOW_ALL),
  2. Added a test case in packages/aws-cdk-lib/aws-sqs/test/sqs.test.ts when redrivePermission is specified other than BY_QUEUE.
  3. Added an integ test case in packages/@aws-cdk-testing/framework-integ/test/aws-sqs/test/integ.sqs-source-queue-permission.ts

Description of how you validated changes

Added a test case in packages/aws-cdk-lib/aws-sqs/test/sqs.test.ts when redrivePermission is specified other than BY_QUEUE.
Added an integ test case in packages/@aws-cdk-testing/framework-integ/test/aws-sqs/test/integ.sqs-source-queue-permission.ts
And ran the test case.

Checklist


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 bug This issue is a bug. p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Feb 16, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team February 16, 2024 09:20
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@yoshi-d-24 yoshi-d-24 changed the title fix(aws-sqs): correctly output redrivePermission when specified fix(sqs): correctly output redrivePermission when specified Feb 16, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review February 16, 2024 10:11

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@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 Feb 16, 2024
Copy link
Contributor

@go-to-k go-to-k 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 this PR. Looks good, but I made one minor comment.

Comment on lines 756 to 781
test('explicit specification of redrive permission', () => {
const stack = new Stack();
new sqs.Queue(stack, 'Queue', {
redriveAllowPolicy: {
redrivePermission: sqs.RedrivePermission.DENY_ALL,
},
});

Template.fromStack(stack).templateMatches({
'Resources': {
'Queue4A7E3555': {
'Type': 'AWS::SQS::Queue',
'Properties': {
'RedriveAllowPolicy': {
'redrivePermission': 'denyAll',
},
},
'UpdateReplacePolicy': 'Delete',
'DeletionPolicy': 'Delete',
},
},
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be better with test.each.

Suggested change
test('explicit specification of redrive permission', () => {
const stack = new Stack();
new sqs.Queue(stack, 'Queue', {
redriveAllowPolicy: {
redrivePermission: sqs.RedrivePermission.DENY_ALL,
},
});
Template.fromStack(stack).templateMatches({
'Resources': {
'Queue4A7E3555': {
'Type': 'AWS::SQS::Queue',
'Properties': {
'RedriveAllowPolicy': {
'redrivePermission': 'denyAll',
},
},
'UpdateReplacePolicy': 'Delete',
'DeletionPolicy': 'Delete',
},
},
});
});
test.each([
[sqs.RedrivePermission.ALLOW_ALL, 'allowAll'],
[sqs.RedrivePermission.DENY_ALL, 'denyAll'],
])('redrive permission can be set to %s', (permission, expected) => {
const stack = new Stack();
new sqs.Queue(stack, 'Queue', {
redriveAllowPolicy: {
redrivePermission: permission,
},
});
Template.fromStack(stack).templateMatches({
'Resources': {
'Queue4A7E3555': {
'Type': 'AWS::SQS::Queue',
'Properties': {
'RedriveAllowPolicy': {
'redrivePermission': expected,
},
},
'UpdateReplacePolicy': 'Delete',
'DeletionPolicy': 'Delete',
},
},
});
});

@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 Feb 17, 2024
@go-to-k
Copy link
Contributor

go-to-k commented Feb 17, 2024

And a better title for the PR would be something like fix(sqs): `redrivePermission` is set to `byQueue` no matter what value is specified. This is because a fix PR should indicate what kind of bug it is, not how it was fixed.

@yoshi-d-24 yoshi-d-24 changed the title fix(sqs): correctly output redrivePermission when specified fix(sqs): redrivePermission is set to byQueue no matter what value is specified Feb 18, 2024
@github-actions github-actions bot added the effort/small Small work item – less than a day of effort label Feb 18, 2024
@yoshi-d-24 yoshi-d-24 force-pushed the fix/sqs-redrive-permission branch 2 times, most recently from d5d5746 to fec5054 Compare February 18, 2024 06:32
@yoshi-d-24 yoshi-d-24 force-pushed the fix/sqs-redrive-permission branch from fec5054 to 9ea12d1 Compare February 18, 2024 06:38
@yoshi-d-24
Copy link
Contributor Author

@go-to-k
Updated as you pointed out. Thank you.

Copy link
Contributor

@go-to-k go-to-k left a comment

Choose a reason for hiding this comment

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

Thanks.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 18, 2024
kaizencc
kaizencc previously approved these changes Feb 19, 2024
Copy link
Contributor

@kaizencc kaizencc 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 the fix @yoshi-d-24

Copy link
Contributor

mergify bot commented Feb 19, 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 Feb 19, 2024
Copy link
Contributor

mergify bot commented Feb 19, 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).

@mergify mergify bot dismissed kaizencc’s stale review February 19, 2024 23:45

Pull request has been modified.

@yoshi-d-24 yoshi-d-24 requested a review from kaizencc February 19, 2024 23:57
@yoshi-d-24
Copy link
Contributor Author

@kaizencc
Sorry, I accidentally pushed Update Branch button and merged main.
Can you please review it again?

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 20, 2024
gracelu0
gracelu0 previously approved these changes Mar 1, 2024
Copy link
Contributor

mergify bot commented Mar 1, 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 Mar 1, 2024
Copy link
Contributor

mergify bot commented Mar 1, 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).

@mergify mergify bot dismissed gracelu0’s stale review March 1, 2024 18:20

Pull request has been modified.

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

mergify bot commented Mar 1, 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 Mar 1, 2024
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: a6d16ef
  • 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 aa8484a into aws:main Mar 1, 2024
12 checks passed
Copy link
Contributor

mergify bot commented Mar 1, 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).

godwingrs22 pushed a commit to godwingrs22/aws-cdk that referenced this pull request Mar 1, 2024
…e is specified (aws#29130)

### Issue aws#29129

Closes aws#29129.

### Reason for this change

When `redriveAllowPolicy.redrivePermission` is specified, any value will be output to template as `byQueue`

### Description of changes

1. Fix the evaluation order by enclosing the ternary operators in parentheses
   ```typescript
        ?? (props.redriveAllowPolicy.sourceQueues ? RedrivePermission.BY_QUEUE : RedrivePermission.ALLOW_ALL),
   ```
2.  Added a test case in `packages/aws-cdk-lib/aws-sqs/test/sqs.test.ts` when redrivePermission is specified other than `BY_QUEUE`.
3. Added an integ test case in `packages/@aws-cdk-testing/framework-integ/test/aws-sqs/test/integ.sqs-source-queue-permission.ts`

### Description of how you validated changes

Added a test case in `packages/aws-cdk-lib/aws-sqs/test/sqs.test.ts` when redrivePermission is specified other than `BY_QUEUE`.
Added an integ test case in `packages/@aws-cdk-testing/framework-integ/test/aws-sqs/test/integ.sqs-source-queue-permission.ts`
And ran the test case.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*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
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-sqs: redriveAllowPolicy.redrivePermission is not working correctly
5 participants