-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Destroy aws_ecs_service.service on Fargate gets stuck #3414
Comments
Is this going to be looked into? Are there any workarounds? (preferably without manual intervention) |
The ecs_service resource delete operation still does a draining of tasks within a service. This might not be an open issue anymore? @bflad ? |
This is happening to me, as well. The CLI gets stuck on Terraform v0.11.13 |
Hello all, I'm also getting this issue with Terraform v0.12.6 and AWSProvider v2.23.0 This is my ECS configuration, excluding load balancer and other network-related resources (replacing details with "X"):
Once it starts to destroy my ecs resources, it hangs at I am currently looking into using the local-exec provisioner to execute AWS CLI commands on the destroy stage for the service resource in order to automatically stop all tasks running in it as a workaround. |
So I managed to get the aforementioned workaround working for my specific case, I created a shell script that gets executed by Terraform to stop the EC2 task before destroying the service so that it won't get stuck. This requires the AWS CLI to be installed and configured on the same machine. Here is what it looks like:
Copy and paste the script somewhere in your module or root such as in {module}/scripts/stop-tasks.sh and inside your ecs service resource add the local-exec provisioner so it looks something like this:
I haven't tested it in other situations, but feel free to use and modify at your leisure! I hope this issue gets fixed soon |
Following up with another possible workaround, for any who need it. We took inspiration from @bavibm's solution and implemented a destroy provisioner on the cluster resource which stops all tasks, idles the service, and waits for things to reach a state where the cluster itself can be destroyed. The important part of your script:
Your cluster definition:
Because of hashicorp/terraform#23679, we are only relying on |
this happened to me as well. i had to delete ECS security group from the RDS security group manually. |
This is happening to me. If I try to delete the security group manually (through Amazon console), it says it is being used by a network interface. If I try to delete the network interface, it says it is being used by the security group. |
Still happening any solution?
(It hit almost 6 mins before I manually killed the job) Manually required to run: |
Update: Seems as the team is aware of the issue and have suggested adding a I was able to get it working here without having to add any extra scripts. Finished in around 2m40s. (Could be related to the timeout of the container while draining) Edit: Looks as per the docs:
Therefore it will be Overall if you don't add the Most likely the issue can be closed 📕 |
I "fixed" this by setting the desired count to zero, similar to what others as previously done:
I guess this should be done automatically by the provider. |
If your service has a static
Set
This should make |
Destroy gets stuck on resource
aws_ecs_service
on Fargate until you manuallystop all
the tasks.Terraform Version
Terraform v0.11.3
Affected Resource(s)
Please list the resources as a list, for example:
Terraform Configuration Files
Debug Output
Expected Behavior
In order to destroy the Fargate ECS tasks it should
stop all
the service tasks.Actual Behavior
I gets stuck trying to destroy the resource.
Steps to Reproduce
Simple launch a Fargate cluster using
launch_type = "FARGATE"
terraform apply
terraform destroy
The text was updated successfully, but these errors were encountered: