fix(sqs): redrivePermission is set to byQueue no matter what value is specified#29130
Conversation
aws-cdk-automation
left a comment
There was a problem hiding this comment.
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.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
go-to-k
left a comment
There was a problem hiding this comment.
Thanks for this PR. Looks good, but I made one minor comment.
| 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', | ||
| }, | ||
| }, | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Might be better with test.each.
| 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', | |
| }, | |
| }, | |
| }); | |
| }); |
|
And a better title for the PR would be something like |
redrivePermission is set to byQueue no matter what value is specified
d5d5746 to
fec5054
Compare
fec5054 to
9ea12d1
Compare
|
@go-to-k |
kaizencc
left a comment
There was a problem hiding this comment.
Thanks for the fix @yoshi-d-24
|
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). |
|
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). |
Pull request has been modified.
|
@kaizencc |
|
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). |
|
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). |
|
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
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). |
…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*
Issue #29129
Closes #29129.
Reason for this change
When
redriveAllowPolicy.redrivePermissionis specified, any value will be output to template asbyQueueDescription of changes
packages/aws-cdk-lib/aws-sqs/test/sqs.test.tswhen redrivePermission is specified other thanBY_QUEUE.packages/@aws-cdk-testing/framework-integ/test/aws-sqs/test/integ.sqs-source-queue-permission.tsDescription of how you validated changes
Added a test case in
packages/aws-cdk-lib/aws-sqs/test/sqs.test.tswhen redrivePermission is specified other thanBY_QUEUE.Added an integ test case in
packages/@aws-cdk-testing/framework-integ/test/aws-sqs/test/integ.sqs-source-queue-permission.tsAnd 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