Why would you use the terraform taint command?
Why would you use the terraform taint command?
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.
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
IMPORTANT NOTE: taint command is deprecated. For Terraform v0.15.2 and later, Hashicorp recommends using the -replace option with terraform apply instead
This command is now deprecated and suggested option is now terraform apply -replace="state_object" . Ans B
it is B
b it is
https://www.terraform.io/cli/commands/taint#recommended-alternative
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
yes but on the exam it's still a valid answer
Outdated question for v3.0.0 test. Although B is correct, but we now have terraform -replace="resource_name" for this now.
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
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.
B. When you want to force Terraform to destroy and recreate a resource on the next apply
B is correct
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.