Recently, we encountered an issue regarding the destruction of a specific resource.
The version of Terraform is 0.12.29. We are using Terraform on GCP. During a terraform apply command one of the disks that are created and attached to an instance got destroyed.
Let me give some background information: We are using Terraform behind an internal web service, which receives input from users and populates auto.tfvars files and creates the infrastructure using the values from those auto.tfvars files. I’m pretty sure that, there is something wrong with the web service part but I want to understand in which cases only a specific resource can be destroyed while others stay as they are. So we can improve the web service part to prevent this kind of destruction.
One idea is the resource might be marked as tainted. For some reason, Terraform might have done this but in this case, the resource should have been recreated as far as I know. But it didn’t get created.
For what other reasons a “terraform apply” operation can delete a resource but keep the others intact in the same infrastructure? Any ideas?
Thanks in advance,