TA-002-P · Question #118
Which Terraform command will force a marked resource to be destroyed and recreated on the next apply?
The correct answer is C. terraform taint. The terraform taint <resource> command manually marks a resource as 'tainted' in the state file. On the next terraform apply, Terraform will destroy and recreate that resource. This is useful when a resource is in a degraded or unknown state without changing the configuration…
Question
Which Terraform command will force a marked resource to be destroyed and recreated on the next apply?
Options
- Aterraform fmt
- Bterraform destroy
- Cterraform taint
- Dterraform refresh
How the community answered
(21 responses)- B5% (1)
- C90% (19)
- D5% (1)
Explanation
The terraform taint <resource> command manually marks a resource as 'tainted' in the state file. On the next terraform apply, Terraform will destroy and recreate that resource. This is useful when a resource is in a degraded or unknown state without changing the configuration. terraform fmt (A) only reformats code. terraform destroy (B) destroys all resources, not just one. terraform refresh (D) updates the state file to match real-world infrastructure but does not force recreation. Note: In Terraform v0.15.2+, terraform taint was superseded by terraform apply -replace=<resource>.
Topics
Community Discussion
No community discussion yet for this question.