nerdexam
HashiCorp

TERRAFORM-ASSOCIATE-003 · 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…

The correct answer is B. Use the terraform taint command targeting the VMs then run terraform plan and terraform apply. The terraform taint command marks a resource as tainted, which means it will be destroyed and recreated on the next apply. This way, you can replace the VM instance without affecting the database or other resources.

Use the Core Terraform Workflow

Question

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?

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

(31 responses)
  • A
    10% (3)
  • B
    81% (25)
  • C
    6% (2)
  • D
    3% (1)

Explanation

The terraform taint command marks a resource as tainted, which means it will be destroyed and recreated on the next apply. This way, you can replace the VM instance without affecting the database or other resources.

Topics

#terraform taint#resource replacement#targeted operations#core workflow

Community Discussion

No community discussion yet for this question.

Full TERRAFORM-ASSOCIATE-003 Practice