You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem
The problem is when we do destroy via plan -destroy resources list is not getting completely cleaned-up leaving resources in the state file. The issue does not manifest itself until there is a dependency on the resource and destroy (via plan)>apply was called. In our case we did plan -destroy with subsequent apply (sandbox environment) which resulted in error because we had output of the module with depends_on condition on the resource created. Because resource which had depends_on also had count it was present in the state file after the original destroy hence module considered this resource as already created for the depends_on condition and our output logic was broken so did our infrastructure pipeline.
Expected behaviour
both plan -destroy and destroy should leave no resources in the state file.
How to reproduce
main.tf
data "null_data_source" "values" {
count = 1
inputs = {
name = "test"
}
}
terraform plan -destroy -out=plan.out
terraform apply plan.out
jbardin
changed the title
destroy operation with terraform plan -destroy produce different state files to terraform destroy if resource have count on it
leftover module in state that should have been removed
Jan 10, 2020
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
ghost
locked and limited conversation to collaborators
Mar 28, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Terraform version: 0.12.19
Problem
The problem is when we do destroy via plan -destroy resources list is not getting completely cleaned-up leaving resources in the state file. The issue does not manifest itself until there is a dependency on the resource and destroy (via plan)>apply was called. In our case we did plan -destroy with subsequent apply (sandbox environment) which resulted in error because we had output of the module with depends_on condition on the resource created. Because resource which had depends_on also had count it was present in the state file after the original destroy hence module considered this resource as already created for the depends_on condition and our output logic was broken so did our infrastructure pipeline.
Expected behaviour
both plan -destroy and destroy should leave no resources in the state file.
How to reproduce
main.tf
terraform plan -destroy -out=plan.out
terraform apply plan.out
more terraform.tfstate
terraform destroy
more terraform.tfstate
The text was updated successfully, but these errors were encountered: