Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 24


Why would you use the terraform taint command?

Show Answer
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

15 comments
Sign in to comment
EltoothOption: B
Jan 6, 2023

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
Jul 25, 2024

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

softarts
Nov 16, 2022

it is B

Power123
Sep 30, 2023

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

d0ug7979
Nov 10, 2022

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
Nov 23, 2022

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

javibadilloOption: B
Dec 8, 2022

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

BlackZerosOption: B
Dec 26, 2022

b it is

SilentMilliOption: B
Aug 11, 2023

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.

HalimbOption: B
Mar 1, 2024

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

Jerry_m10
May 21, 2024

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

Bilalglg93350
Sep 14, 2023

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.

Ni33Option: B
Nov 1, 2023

B is correct

karendavtyanOption: B
Nov 5, 2023

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

lazy_tortoise89Option: B
Dec 29, 2024

The answer is B here. But I came across to the other question related to taint and it is important to give attention to the small but Important point: Changes will be applied in the NEXT apply, after you run taint command to mark the resource "as delete".

instant919Option: B
Jan 18, 2025

B. When you want to force Terraform to destroy and recreate a resource on the next apply Using the terraform taint command marks a resource as "tainted," which means that Terraform will destroy and then recreate the resource during the next terraform apply operation. This can be useful if you know that a resource is in a bad state and needs to be replaced.