-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(aws-ecs): Can't delete a stack with ASG Capacity providers #14732
Comments
I believe the reason for this is because the default for managed termination protection is set to Two ways you can get around this:
I am still investigating if there are other ways around this while still creating an ASG with managed termination protection, but see if either of the above works for you @hnrc ! |
Thanks for looking into this. Both workarounds work me. |
Great, glad the workarounds helped! Closing this issue. |
|
Deleting stacks using ECS clusters having capacityProviders (i.e. dual-primary and primary-replica recipes), fails with: ``` The Cluster cannot be deleted while Container Instances are active or draining. ``` This is an issue that manifests itself as well via terraform [1] or CDK [2]. Explicitly deleting the Autoscaling Groups _before_ the ECS cluster deletion fixes the problem, since it ensures that no instances are active or draining, as the error suggests. This is safe to do, because prior to deleting the Autoscaling Groups, every ECS service has already been destroyed, thus no instance is actually running. [1] hashicorp/terraform-provider-aws#4852 [2] aws/aws-cdk#14732 Bug: Issue 14698 Change-Id: I216307ef88bd7b7317706d2dc0a6a6e6fb367bd4 Change-Id: I27ece0f6971b157a474d91d7f3d9243dcff596e6
Experiencing the same issue with the defaults in
edit: I later created a new issue for this: #18179. |
@SoManyHs this is still an issue, since we have to use manual hacks to destroy the stack. |
Hey all, I've created a reference CloudFormation template that demonstrates how to avoid this issue. The end to end solution for the capacity provider with working teardown can be found here: https://containersonaws.com/pattern/ecs-ec2-capacity-provider-scaling You can also refer directly to the sample code for the Lambda function here: https://github.com/aws-samples/container-patterns/blob/main/pattern/ecs-ec2-capacity-provider-scaling/files/cluster-capacity-provider.yml#L48-L123 In short, this solution implements a custom ASG destroyer resource, which is used to force kill the ASG so that it does not block the CloudFormation stack teardown. A similar approach could be implemented in CDK. I've added a todo item for me to make a CDK specific example as well. |
It seem to not be possible to gracefully uninstall an ECS cluster that is associated with an ASG Capacity Provider.
CF hangs and never really finishes, unless one manually deletes the ASG.
Reproduction Steps
What did you expect to happen?
The CF stack should be properly and gracefully removed.
What actually happened?
The CF stack got stuck in
DELETE_IN_PROGRESS
AWS::EC2::InternetGateway
AWS::ECS::Cluster
AWS::AutoScaling::LaunchConfiguration
AWS::AutoScaling::AutoScalingGroup:
The stack finished deleting after I manually removed the ASG.
Environment
Other
This seems like a related discussion: aws/containers-roadmap#631 (comment)
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: