Skip to content

(aws-ecs-patterns): QueueProcessingServiceBase does not respect a minScalingCapacity: 0 #14336

@wittekm

Description

@wittekm

In the following code:

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.minScalingCapacity of 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ecs-patternsRelated to ecs-patterns librarybugThis 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