Exam Terraform Associate All QuestionsBrowse all questions from this exam
Question 124

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?

    Correct Answer: B

    The best way to replace a virtual machine instance with an identical one without affecting the database is to use the terraform taint command. This command marks a resource for recreation, which means that on the next run of terraform apply, Terraform will destroy and recreate the tainted resource. This approach ensures that only the specific virtual machine instance is replaced, leaving the other resources, such as the database, unaffected.

Discussion
KJ_RollingsOption: B

B. for v0.15.2 and later, you can also use "terraform apply -replace=ADDRESS" to achieve the same result.

keiffo2Option: B

terraform apply -target - just looks at applying part of the config. In this case we'd need to taint the resource and then run an apply. Just to note taint is now deprecated - seems like it comes up in the exam mind, instead of using taint you should use terrform apply -replace=aws_instance.my_server

keiffo2

So answer B

alirasouli

Exactly I was thinking about `terraform apply -replace=...`, so answer C can also be correct. Of course answer B is also correct and deprecated!

Spandrop

being taint deprecated, I would go with C.

depal_dhirOption: B

https://www.terraform.io/cli/state/taint

junk4shareOption: B

ITS B.

adoubanOption: B

B correct