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 achieve this using Terraform?
A.
Use the Terraform taint command targeting the VMs then run Terraform plan and Terraform apply
B.
Delete the Terraform VM resources from your Terraform code then run Terraform plan and terraform apply
C.
Use the terraform apply command targeting the VM resources only
D.
Use the terraform state rm command to remove the VM from state file
Answer:
A
User Votes:
A 1 votes
50%
B
50%
C
50%
D
50%
Discussions
0/ 1000
Aamir_Ahmed
4 weeks ago
B. Delete the Terraform VM resources from your Terraform code then run terraform plan and terraform apply. ❌
This would remove the VM entirely, rather than replacing it. C. Use the terraform apply command targeting the VM resources only. ❌
Running terraform apply without marking the resource for recreation will not replace the existing VM. D. Use the terraform state rm command to remove the VM from the state file. ❌
This removes Terraform’s knowledge of the VM but does not actually recreate it. Terraform would treat it as unmanaged unless redefined in the code, potentially leading to orphaned resources.
Want to join our community?
Please log in or signup in order to use this feature
B. Delete the Terraform VM resources from your Terraform code then run terraform plan and terraform apply. ❌
This would remove the VM entirely, rather than replacing it.
C. Use the terraform apply command targeting the VM resources only. ❌
Running terraform apply without marking the resource for recreation will not replace the existing VM.
D. Use the terraform state rm command to remove the VM from the state file. ❌
This removes Terraform’s knowledge of the VM but does not actually recreate it.
Terraform would treat it as unmanaged unless redefined in the code, potentially leading to orphaned resources.