-
Notifications
You must be signed in to change notification settings - Fork 4.4k
(aws-ecs-patterns): QueueProcessingServiceBase does not respect a minScalingCapacity: 0 #14336
Description
In the following code:
aws-cdk/packages/@aws-cdk/aws-ecs-patterns/lib/base/queue-processing-service-base.ts
Line 312 in 75c96d7
| } else { |
I am in a situation where:
- I have turned on
this.node.setContext(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT, true);(putting me in the else-else clause on line 312) - I am creating a
new ecs_patterns.QueueProcessingFargateService - I'm feeding in a
props.minScalingCapacityof 0 - which appears to be a completely valid number when using the ECS UI - but that is being overridden by the|| 1
Reproduction Steps
Described reasonably well above. Create a new ecs_patterns.QueueProcessingFargateService with minScalingCapacity: 0 and inspect the generated Cfn template; it'll show a non-zero for MinCapacity. In my case:
"apr23sysmongeneratorserviceQueueProcessingFargateServiceTaskCountTargetAE4E3513": {
"Type": "AWS::ApplicationAutoScaling::ScalableTarget",
"Properties": {
"MaxCapacity": 5,
"MinCapacity": 1,
"ResourceId": {
What did you expect to happen?
Create a Cfn AWS::ApplicationAutoScaling::ScalableTarget with MinCapacity: 0
What actually happened?
Created a Cfn AWS::ApplicationAutoScaling::ScalableTarget with MinCapacity: 1
Environment
- Framework Version: 1.97.0
Other
Suggested solution:
Consider using = props.minScalingCapacity ?? 1 - this is the new Typescript Nullish Coalescing Operator, which slightly differs from || in that it will accept values like 0 and false, instead of falling through to the backup.
In general, you'd probably want to do a serious audit of all uses of x = x || y in cases where, say, 0 is a valid prop.
This is 🐛 Bug Report