Skip to content

[ECS] Clean up ASG instance scale-in protection when ECS Capacity Provider is deleted #2862

Description

@BWashishtha

Description:

When an ECS Capacity Provider with ManagedTerminationProtection enabled is deleted, the ProtectedFromScaleIn flags that ECS set on the associated Auto Scaling Group instances are never removed. This leaves instances permanently protected from scale-in, which blocks ASG deletion and causes CloudFormation stack delete operations to fail.

Expected behavior:

When a Capacity Provider is deleted (or disassociated from a cluster), ECS should remove the ProtectedFromScaleIn flag from all instances in the associated ASG that were protected by ECS managed termination protection. Since ECS is removing its association with the ASG, its lifecycle hooks will no longer manage those instances, and the protection flags are no longer meaningful.

Current behavior:

  1. Customer creates a Capacity Provider with ManagedTerminationProtection: ENABLED and associates it with an ASG
  2. ECS sets ProtectedFromScaleIn=true on ASG instances
  3. Customer deletes the Capacity Provider
  4. Instance-level scale-in protection flags remain set on the ASG instances
  5. The ASG cannot be deleted (CloudFormation returns ScalingActivityInProgress or similar), blocking stack cleanup
    Impact:

Customers using CloudFormation or CDK to manage ECS infrastructure with capacity providers cannot cleanly tear down their stacks. The only workaround is to manually remove scale-in protection from each instance via the Auto Scaling API before retrying the stack deletion.

Related: aws-cdk#18179

Metadata

Metadata

Assignees

Labels

ECSAmazon Elastic Container ServiceProposedCommunity submitted issue

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions