nerdexam
HashiCorp

TA-002-P · Question #205

Forcing the recreation of a resource is useful when you want a certain side effect of recreation that is not visible in the attributes of a resource. What command will do this?

The correct answer is A. terraform taint. terraform taint marks a specific resource instance in the state file as 'tainted,' meaning it is flagged for destruction and recreation on the next terraform apply. This is useful when a resource's visible attributes are correct but some out-of-band state (e.g., a corrupted VM…

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

Question

Forcing the recreation of a resource is useful when you want a certain side effect of recreation that is not visible in the attributes of a resource. What command will do this?

Options

  • Aterraform taint
  • Bterraform apply
  • Cterraform graph
  • Dterraform refresh

How the community answered

(22 responses)
  • A
    86% (19)
  • B
    5% (1)
  • C
    9% (2)

Explanation

terraform taint marks a specific resource instance in the state file as 'tainted,' meaning it is flagged for destruction and recreation on the next terraform apply. This is useful when a resource's visible attributes are correct but some out-of-band state (e.g., a corrupted VM disk, an expired certificate, a misconfigured bootstrapping script) needs to be reset by reprovisioning. Note: as of Terraform v0.15.2+, terraform taint is deprecated in favor of terraform apply -replace=<resource_address>, which achieves the same result more directly. For exam purposes, terraform taint remains the classic answer. The other options (apply, graph, refresh) do not force recreation.

Topics

#terraform taint#resource recreation#CLI commands#resource lifecycle

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice