-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Terraform shouldn't remove deposed resources that have the same id of a resource just created #20360
Comments
Hi @mildred, Thanks for filing the issue! While Terraform will not be able to determine what constitutes a unique identifier for a resource, I think it might be a good idea to try checking if a new instance is completely equal to its deposed instance and remove it from the state. |
When the name for an auto scaling group changes, terraform knows it has to create a new resource. Can't that information be used to determine that if an identical named resource was created, it's no longer to be removed ? Another way to fix this without having terraform knows about unique resource identifiers, would be to check during the plan phase if deposed resources are still there, and if deposed resources are detected as not existing, remove them from the state at that moment. |
Terraform does not have any way of knowing that a specific attribute must be unique between resources. The provider may have that information, but the best it can do is return an error when you attempt to create the duplicate resource. The reason this doesn't come up often, is that if you cannot create multiple instances of a resource from the same config, you cannot use |
Hi,
|
Terraform Version
terraform 0.11.10
Terraform Configuration Files
Actual Behavior
In the following scenario, terraform is removing the auto scaling group it just created:
terraform starts and tries to create the ASG
terraform creates the launch configuration "terraform-20190215140012211400000002"
terraform creates an ASG with the name "etcd_server - terraform-20190215140012211400000002"
the ASG health check fails, and terraform fails with an error like:
the error is on the infrastructure, some changes are made to the infrastructure outside of terraform
the ASG is deleted manually
no modifications are made in terraform itself, terraform is executed again, it should work
terraform sees that the ASG "etcd_server - terraform-20190215140012211400000002" does not exists (the previous one failed too) and it creates it
terraform still remembers of the previous ASG named exactly the same and removes it
Log messages for this:
Here, terraform creates a resource and destroys it right after
Expected Behavior
Either:
The text was updated successfully, but these errors were encountered: