Skip to content

Commit

Permalink
fix(sqs): queue with fifo: false does not deploy (#31922)
Browse files Browse the repository at this point in the history
The `FifoQueue` property in CloudFormation can only be `true`, or must be absent. If you pass `FifoQueue: false`, you will receive the following error:

```
Resource handler returned message: "Unknown Attribute FifoQueue.
(Service: Sqs, Status Code: 400, Request ID: e27d9d99-fe35-5b36-b670-c200419bc975)" (RequestToken: 1d882ab3-52e8-7e4b-e2d3-58e6ba10141d, HandlerErrorCode: InvalidRequest)
```

Make it so that a `fifo: false` configuration doesn't output FifoQueue at all.

Closes #8550.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored Oct 28, 2024
1 parent 186b8ab commit a9d3b02
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/aws-cdk-lib/aws-sqs/lib/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down
22 changes: 22 additions & 0 deletions packages/aws-cdk-lib/aws-sqs/test/sqs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit a9d3b02

Please sign in to comment.