-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
ECS plan fails if cluster has been deleted outside Terraform #15917
Comments
I should also add our current work around is to run |
The fix for this has been merged and will release in version 3.15.0 of Terraform AWS Provider, later this week. Thanks to @adam-tylr for the implementation. 👍 |
This has been released in version 3.15.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Terraform CLI and Terraform AWS Provider Version
Affected Resource(s)
Terraform Configuration Files
Service.json is taken straight from the example in the docs https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ecs_task_definition
Debug Output
I cannot provide the full debug output because of security restrictions with my employer but this is the relevant section:
Panic Output
Expected Behavior
I created an ECS cluster with an associated service then manually deleted the cluster and the service in the console (or as part of a regular clean up script). When I run a plan again, I expect it to produce a valid plan to re-create the cluster and the service.
Actual Behavior
I created an ECS cluster with an associated service then manually deleted the cluster and the service in the console. When I run a plan again, terraform outputs
Error: Error reading ECS service: ClusterNotFoundException: Cluster not found.
Steps to Reproduce
terraform apply
to create the cluster and serviceterraform plan
Important Factoids
When an ECS cluster and service are deleted, they are put in an inactive state and disappear from the UI but are not actually removed from the account. Described Here. As long as they exist in an inactive state there is no issue. What we've seen happen is the cluster being removed completely such that
aws ecs describe-clusters --clusters <cluster-arn>
produces an error instead of returning an inactive cluster. During the failed plan I see a sequence of events like:ecs/DescribeClusters
with the expected cluster ARN from state[WARN] ECS Cluster (arn:aws:ecs:us-east-1::cluster/my-cluster) not found, removing from state
ecs/DescribeServices
with the expected service and cluster ARN from stateSo it seems like terraform needs to interpret a ClusterNotFoundException as a sign of needing to re-create the service.
It's difficult to fully replicate the issue because it depends on the cluster being removed from the account. I'm not sure how long that takes. I've had two internal customers come to me with this issue within 2 weeks of an account clean up. I was able to re-create for my simple example by updating the state of the service to point to a cluster that never existed.
References
The text was updated successfully, but these errors were encountered: