From 982cfb54390f0b9df48a67c7d0d01ec0b0b087ac Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Mon, 28 Oct 2024 18:04:16 +0100 Subject: [PATCH] fix(sqs): Queue with `fifo: false` does not deploy The `FifoQueue` property in CloudFormation can only be `true`, or must be absent. Make it so that a `fifo: false` configuration doesn't output FifoQueue at all. Closes #8550. --- packages/aws-cdk-lib/aws-sqs/lib/queue.ts | 6 ++++- packages/aws-cdk-lib/aws-sqs/test/sqs.test.ts | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-sqs/lib/queue.ts b/packages/aws-cdk-lib/aws-sqs/lib/queue.ts index e0e5503c3704c..d05f886cc22a8 100644 --- a/packages/aws-cdk-lib/aws-sqs/lib/queue.ts +++ b/packages/aws-cdk-lib/aws-sqs/lib/queue.ts @@ -560,7 +560,11 @@ export class Queue extends QueueBase { contentBasedDeduplication: props.contentBasedDeduplication, deduplicationScope: props.deduplicationScope, fifoThroughputLimit: props.fifoThroughputLimit, - fifoQueue, + + // This value will be passed directly into the L1 props, but the underlying `AWS::SQS::Queue` + // does not accept `FifoQueue: false`. It must either be `true` or absent. So change a `false` into + // an `undefined`. + fifoQueue: fifoQueue ? true : undefined, }; } diff --git a/packages/aws-cdk-lib/aws-sqs/test/sqs.test.ts b/packages/aws-cdk-lib/aws-sqs/test/sqs.test.ts index 0ae7bc2919ef5..690eb0ec275be 100644 --- a/packages/aws-cdk-lib/aws-sqs/test/sqs.test.ts +++ b/packages/aws-cdk-lib/aws-sqs/test/sqs.test.ts @@ -675,6 +675,28 @@ test('test a queue throws when deduplicationScope specified on non fifo queue', }).toThrow(); }); +test('fifo: false is dropped from properties', () => { + // GIVEN + const stack = new Stack(); + + // WHEN + new sqs.Queue(stack, 'Queue', { + fifo: false, + }); + + // THEN + Template.fromStack(stack).templateMatches({ + 'Resources': { + 'Queue4A7E3555': { + 'Type': 'AWS::SQS::Queue', + 'Properties': Match.absent(), + 'UpdateReplacePolicy': 'Delete', + 'DeletionPolicy': 'Delete', + }, + }, + }); +}); + test('test metrics', () => { // GIVEN const stack = new Stack();