TERRAFORM-ASSOCIATE-004 · Question #70
You've used Terraform to deploy a virtual machine and a database. You want to replace this virtual machine instance with an identical one without affecting the database. What is the best way to achiev
The correct answer is B. Use the terraform taint command targeting the VMs then run terraform plan and terraform apply. The terraform taint <resource_address> command marks a specific resource for replacement in the next apply. When you subsequently run terraform plan and terraform apply, Terraform will destroy and recreate only that tainted resource (the VM), leaving all other resources (like the
Question
Options
- AUse the terraform state rm command to remove the VM from state file
- BUse the terraform taint command targeting the VMs then run terraform plan and terraform apply
- CUse the terraform apply command targeting the VM resources only
- DDelete the Terraform VM resources from your Terraform code then run terraform plan and
How the community answered
(41 responses)- A2% (1)
- B80% (33)
- C5% (2)
- D12% (5)
Explanation
The terraform taint <resource_address> command marks a specific resource for replacement in the next apply. When you subsequently run terraform plan and terraform apply, Terraform will destroy and recreate only that tainted resource (the VM), leaving all other resources (like the database) untouched. Note: In Terraform 0.15.2+, the preferred approach is terraform apply -replace=<resource_address>, which combines the taint and apply steps. However, terraform taint remains the answer referenced in this question context.
Topics
Community Discussion
No community discussion yet for this question.