Skip to content

aws-sqs: redriveAllowPolicy.redrivePermission is not working correctly #29129

@yoshi-d-24

Description

@yoshi-d-24

Describe the bug

Cfn template value is always byQueue, regardless of the value of redriveAllowPolicy.redrivePermission set in the CDK

const myQueueAllowAll = new sqs.Queue(this, 'MyQueueAllowAll', {
  queueName: 'MyQueueAllowAll',
  redriveAllowPolicy: {
      redrivePermission: sqs.RedrivePermission.ALLOW_ALL,
  },
});

const myQueueDenyAll = new sqs.Queue(this, 'MyQueueDenyAll', {
  queueName: 'MyQueueDenyAll',
  redriveAllowPolicy: {
      redrivePermission: sqs.RedrivePermission.DENY_ALL,
  },
});

Expected Behavior

The configured values are output to the Cfn template.

Current Behavior

The value of the Cfn template is always byQueue

{
    "Resources": {
        "MyQueueAllowAllAF132E44": {
            "Type": "AWS::SQS::Queue",
            "Properties": {
                "QueueName": "MyQueueAllowAll",
                "RedriveAllowPolicy": {
                    "redrivePermission": "byQueue"
                }
            }
        },
        "MyQueueDenyAll6B4D4BA9": {
            "Type": "AWS::SQS::Queue",
            "Properties": {
                "QueueName": "MyQueueDenyAll",
                "RedriveAllowPolicy": {
                    "redrivePermission": "byQueue"
                }
            }
        }
    }
}

Reproduction Steps

Generate cfn template with code written in Describe the bug

Possible Solution

Change the expression of redrivePermission.

queue.ts

      redrivePermission: props.redriveAllowPolicy.redrivePermission
      // When `sourceQueues` is provided in `redriveAllowPolicy`, `redrivePermission` defaults to allow specified queues (`BY_QUEUE`);
      // otherwise, it defaults to allow all queues (`ALLOW_ALL`).
        ?? props.redriveAllowPolicy.sourceQueues ? RedrivePermission.BY_QUEUE : RedrivePermission.ALLOW_ALL,

to

      redrivePermission: props.redriveAllowPolicy.redrivePermission
      // When `sourceQueues` is provided in `redriveAllowPolicy`, `redrivePermission` defaults to allow specified queues (`BY_QUEUE`);
      // otherwise, it defaults to allow all queues (`ALLOW_ALL`).
        ?? (props.redriveAllowPolicy.sourceQueues ? RedrivePermission.BY_QUEUE : RedrivePermission.ALLOW_ALL),

Additional Information/Context

No response

CDK CLI Version

2.128.0

Framework Version

No response

Node.js Version

v20.11.0

OS

Windows 11

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-sqsRelated to Amazon Simple Queue ServicebugThis issue is a bug.effort/smallSmall work item – less than a day of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions