aws / aws/aws-cdk

aws_ecs: Previously turned on managed scaling cannot be disabled

Open
#29,088 2 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-ecs bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### Describe the bug

If you create a ECS cluster with `AsgCapacityProvider` with managed scaling enabled, you are not able to disable it any time later.

Once the `EneableManagedScaling` is set to false, the outputted CloudFormation template does not contain the definition for [`ManagedScaling` property](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ecs-capacityprovider-managedscaling.html#cfn-ecs-capacityprovider-managedscaling-status) anymore, but this is not causing the CloudFormation to turn off the managed scaling.

### Expected Behavior

Setting `AsgCapacityProvider.EnableManagedScaling` to `false` should turned off the managing scaling.

### Current Behavior

When `AsgCapacityProvider.EnableManagedScaling` is set to `false` for the capacity provider, CloudFormation template does not contain `ManagedScaling` property for `AWS::ECS::CapacityProvider` anymore. But this missing property doesn't cause the managed scaling to be turned off.

### Reproduction Steps

1. Create a ECS cluster with auto-scale group definition:

```C#
Cluster cluster = new(this, "cluster", new ClusterProps
{
ClusterName = _props.StackName,
Vpc = vpc,
ContainerInsights = true
});

cluster.AddAsgCapacityProvider(new AsgCapacityProvider(this, "asg-provider", new AsgCapacityProviderProps
{
AutoScalingGroup = new AutoScalingGroup(this, "auto-scaling", new AutoScalingGroupProps
{
AutoScalingGroupName = _props.StackName,
Vpc = vpc,
InstanceType = InstanceType.Of(InstanceClass.T3, InstanceSize.NANO),
MinCapacity = 0,
MaxCapacity = 5,
MachineImage = EcsOptimizedImage.AmazonLinux2023(),
InstanceMonitoring = Monitoring.DETAILED,
SecurityGroup = ConstructSecurityGroup(vpc),
Role = CreateInstanceRole()
}),
CapacityProviderName = _props.StackName
}), new AddAutoScalingGroupCapacityOptions());
```

2. After cluster is deployed, change `AsgCapacityProvider` property `EnableManagedScaling` to false.

### Possible Solution

The `ManagedScaling` property should be probably still present but with `Status` set to `DISABLED`.

### Additional Information/Context

Problem occurs only when updating existing cluster. If you create new cluster with scaling disabled, it is created in correct way.

### CDK CLI Version

2.126.0

### Framework Version

2.124.0

### Node.js Version

20.10.0

### OS

Fedora 39

### Language

.NET

### Language Version

8

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at the AsgCapacityProvider implementation and the AWS::ECS::CapacityProvider synthesis for EnableManagedScaling updates. Reproduce the existing-cluster update described in the issue and verify that disabling managed scaling emits ManagedScaling with Status set to DISABLED rather than omitting the property.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, csharp, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.