aws / aws/containers-roadmap

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

Open
#2,862 0 comments 0 reactions 1 assignee Claimed by @BWashishtha View on GitHub
ECS Proposed
Dominant language
Shell
Stars
5.4k
Forks
334
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/aws/aws-cdk/issues/18179)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.