nerdexam
HashiCorp

TA-002-P · Question #175

Once a resource is marked as tainted, the next plan will show that the resource will be _________ and ___________ and the next apply will implement this change.

The correct answer is D. destroyed and recreated. Tainting a resource schedules it to be destroyed and recreated in the next plan and apply cycle, replacing the degraded resource with a fresh instance.

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

Question

Once a resource is marked as tainted, the next plan will show that the resource will be _________ and ___________ and the next apply will implement this change.

Options

  • Arecreated and tainted
  • Bdestroyed and not recreated
  • Ctainted and not destroyed
  • Ddestroyed and recreated

How the community answered

(44 responses)
  • A
    2% (1)
  • C
    2% (1)
  • D
    95% (42)

Why each option

Tainting a resource schedules it to be destroyed and recreated in the next plan and apply cycle, replacing the degraded resource with a fresh instance.

Arecreated and tainted

'Recreated and tainted' is incorrect because while the resource is recreated, the newly created resource is not itself tainted - the taint flag applies only to the old instance to trigger replacement.

Bdestroyed and not recreated

'Destroyed and not recreated' is incorrect because taint always triggers recreation after destruction so Terraform can restore the desired state.

Ctainted and not destroyed

'Tainted and not destroyed' contradicts the fundamental purpose of the taint mechanism, which is specifically to schedule a resource for destruction and replacement.

Ddestroyed and recreatedCorrect

When a resource is tainted, Terraform marks it as needing replacement; the next terraform plan displays the resource as scheduled for destruction followed by creation, and terraform apply executes both steps to restore the resource to a clean state.

Concept tested: Terraform tainted resource lifecycle - destroy and recreate

Source: https://developer.hashicorp.com/terraform/cli/commands/taint

Topics

#Terraform Taint#Resource Lifecycle#Terraform Plan#Terraform Apply

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice