nerdexam
HashiCorpHashiCorp

TA-002-P · Question #309

TA-002-P Question #309: Real Exam Question with Answer & Explanation

The correct answer is D: the resource is marked as tainted. If a resource successfully creates but fails during provisioning, Terraform will error and mark the resource as "tainted". A resource that is tainted has been physically created, but can't be considered safe to use since provisioning failed. Terraform also does not automatically

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

Question

During a terraform plan, a resource is successfully created but eventually fails during provisioning. What happens to the resource?

Options

  • ATerraform attempts to provision the resource up to three times before exiting with an error
  • Bthe terraform plan is rolled back and all provisioned resources are removed
  • Cit is automatically deleted
  • Dthe resource is marked as tainted

Explanation

If a resource successfully creates but fails during provisioning, Terraform will error and mark the resource as "tainted". A resource that is tainted has been physically created, but can't be considered safe to use since provisioning failed. Terraform also does not automatically roll back and destroy the resource during the apply when the failure happens, because that would go against the execution plan: the execution plan would've said a resource will be created, but does not say it will ever be deleted.

Topics

#Tainted resources#Resource provisioning#Error handling#Terraform CLI

Community Discussion

No community discussion yet for this question.

Full TA-002-P PracticeBrowse All TA-002-P Questions