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

Why would you use the terraform taint command?

    Correct Answer: B

    The terraform taint command is used to manually mark a Terraform-managed resource as tainted. This signifies that the resource should be destroyed and recreated during the next terraform apply operation. This is particularly useful when a resource is in an inconsistent state or needs to be replaced for some reason.

Discussion
EltoothOption: B

Noe of the answers really explain what taint command does - except B is closest. "The terraform taint command informs Terraform that a particular object has become degraded or damaged. Terraform represents this by marking the object as "tainted" in the Terraform state, and Terraform will propose to replace it in the next plan you create." https://www.terraform.io/cli/commands/taint

AlandtOption: B

IMPORTANT NOTE: taint command is deprecated. For Terraform v0.15.2 and later, Hashicorp recommends using the -replace option with terraform apply instead

Power123Option: B

This command is now deprecated and suggested option is now terraform apply -replace="state_object" . Ans B

softartsOption: B

it is B

BlackZerosOption: B

b it is

javibadilloOption: B

https://www.terraform.io/cli/commands/taint#recommended-alternative

d0ug7979

This command is now deprecated since v0.15.2 and suggested option is now terraform apply -replace="state_object" https://www.terraform.io/cli/commands/taint#recommended-alternative

biscuithammer

yes but on the exam it's still a valid answer

Jerry_m10Option: B

Outdated question for v3.0.0 test. Although B is correct, but we now have terraform -replace="resource_name" for this now.

HalimbOption: B

Although B is correct here, the question is old and the command is deprecated. Instead use terraform apply -replace="<resource_to_replace>". See https://developer.hashicorp.com/terraform/cli/commands/taint

SilentMilliOption: B

The "terraform taint" command is used to mark a resource as "tainted," indicating to Terraform that the resource should be destroyed and recreated on the next "terraform apply" command. This can be useful in cases where you need to make changes to a resource that cannot be updated in place, or if you want to enforce a clean rebuild of a resource for some other reason. It's important to note that tainting a resource will not immediately destroy the resource, but will instead cause Terraform to plan to destroy and recreate the resource on the next "terraform apply" command. This allows you to review and confirm the changes that Terraform will make before actually applying them.

karendavtyanOption: B

B. When you want to force Terraform to destroy and recreate a resource on the next apply

Ni33Option: B

B is correct

Bilalglg93350Option: C

The correct answer is C. When you want Terraform to ignore a resource on the next apply. The terraform taint command is used to mark a resource managed by Terraform as "tainted," which means that it needs to be recreated on the next apply. This is useful when a resource is in an inconsistent state or needs to be recreated for some other reason. However, the taint command does not destroy or force Terraform to destroy a resource on the next apply (option A and B). Instead, it marks the resource as tainted, indicating that it needs to be recreated. When you run terraform apply after marking a resource as tainted, Terraform will destroy and recreate the resource. Option D is incorrect because the terraform taint command only marks a single resource as tainted and does not destroy all the infrastructure in your workspace.