You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法删除处于DELETE_FAILED状态的AWS CloudFormation堆栈,该怎么办?

Solutions for Stuck CloudFormation Stack in DELETE_FAILED Due to Invalid ECS Service Template

Let’s break down how to fix your stuck stack issue. The root problem is that your invalid YAML syntax (adding a dash before !Ref ClusterName) caused the ECS Service resource to fail creation. Now CloudFormation can’t complete the stack deletion because it’s trying to clean up a resource that’s in an inconsistent or non-existent state. Here are actionable steps to resolve this:

1. Mark the Failed Resource for Retention Before Deletion

This tells CloudFormation to skip trying to delete the problematic Service resource entirely, allowing the rest of the stack to be cleaned up properly. Run these two CLI commands in order:

# First, flag the Service resource to be retained during deletion
aws cloudformation set-stack-resources-to-retain --stack-name service-name --resource-logical-ids Service

# Then delete the stack again
aws cloudformation delete-stack --stack-name service-name

This should bypass the failed resource and let the stack deletion complete successfully.

2. Manually Clean Up Partial ECS Resources (If They Exist)

Even though the stack resource shows CREATE_FAILED, there might be a partial ECS Service left in your account. Verify this with:

aws ecs describe-services --cluster <your-cluster-name> --services <service-name>

If the service exists, delete it manually:

aws ecs delete-service --cluster <your-cluster-name> --service <service-name> --force

Once the service is gone, try deleting the CloudFormation stack again via the console or CLI.

3. Use the CloudFormation Console’s Retain Option (If Available)

After marking the resource for retention via the CLI, you can also use the console to confirm the deletion:

  • Navigate to the CloudFormation console and select your stuck stack.
  • Click Delete.
  • In the confirmation dialog, check the box next to the Service resource to retain it.
  • Confirm the deletion.

4. Contact AWS Support (Last Resort)

If none of the above steps work, reach out to AWS Support. Share your stack ID and the output from describe-stack-resource you provided—they can manually intervene to resolve the stuck stack state.


内容的提问来源于stack exchange,提问作者Dherik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 09:27:34