首页 > 解决方案 > 在ecs aws中运行terraform destroy时,它会先删除一个服务,然后需要很长时间才能删除任务

问题描述

我有 3 个运行任务的 ECS 服务,带有 linux docker 容器和轻量级 web 服务。当我运行时terraform destroy,停止这些任务大约需要 5-6 分钟。

如果在运行时手动停止它们,那么它会继续破坏其他资源。

我的问题是:这是破坏任务的预期时间吗?销毁一个基础ECS集群的整个过程需要8分钟。

使用任务销毁服务的日志:

2019-01-10T17:38:10 [DEBUG] module.ecs.aws_ecs_service.test-service: Still destroying... (ID: arn:aws:ecs:us-east-1:xxxxxxxx:service/test-service, 10s elapsed)
2019-01-10T17:38:11 [DEBUG] plugin.terraform-provider-aws_v1.54.0_x4: 
2019-01-10T17:38:11 [DEBUG] Checking if ECS service arn:aws:ecs:us-east-1:xxxxxxxx:service:service/test-service is INACTIVE
2019-01-10T17:38:11 [DEBUG] plugin.terraform-provider-aws_v1.54.0_x4: 2019-01-10T17:38:11 [DEBUG] [aws-sdk-go] DEBUG: Request ecs/DescribeServices Details:
2019-01-10T17:38:11 [DEBUG] plugin.terraform-provider-aws_v1.54.0_x4: 2019/01/10 17:38:11 [DEBUG] [aws-sdk-go] DEBUG: Response ecs/DescribeServices Details:
2019-01-10T17:38:11 [DEBUG] plugin.terraform-provider-aws_v1.54.0_x4: 2019/01/10 17:38:11 [DEBUG] ECS service (arn:aws:ecs:us-east-1:xxxxxxxx:service/test-service) is currently "DRAINING"
2019-01-10T17:38:11 [DEBUG] plugin.terraform-provider-aws_v1.54.0_x4: 2019/01/10 17:38:11 [TRACE] Waiting 10s before next try

就这样循环了大约 6 分钟。如果我去 AWS 控制台,那么我看不到服务,但我看到状态为“正在运行”的任务,如果我手动停止它们,那么销毁过程将继续到下一个阶段。您可以使用此 repo进行尝试,只需确保将 env 变量TF_LOG设置为至少DEBUG. 在提供的 repo 中将花费更少的时间,但您会看到相同的行为。
谢谢你看这个。

标签: amazon-web-servicesterraformamazon-ecsdestroy

解决方案


推荐阅读