nerdexam
HashiCorpHashiCorp

TA-002-P · Question #223

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

The correct answer is A: The resource will be planned for destruction and recreation upon the next terraform apply. If a creation-time provisioner fails, the resource is marked as tainted. A tainted resource will be planned for destruction and recreation upon the next terraform apply. Terraform does this because a failed provisioner can leave a resource in a semi-configured state. Because Terr

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

Question

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

Options

  • AThe resource will be planned for destruction and recreation upon the next terraform apply
  • BTerraform will retry to provision again.
  • CThe failure of provisioner will be ignored and it will not cause a failure to terraform apply
  • DThe resource will be automatically destroyed.

Explanation

If a creation-time provisioner fails, the resource is marked as tainted. A tainted resource will be planned for destruction and recreation upon the next terraform apply. Terraform does this because a failed provisioner can leave a resource in a semi-configured state. Because Terraform cannot reason about what the provisioner does, the only way to ensure proper creation of a resource is to recreate it. This is tainting. You can change this behavior by setting the on_failure attribute, which is covered in detail below.

Topics

#terraform apply#provisioners#resource lifecycle#error handling

Community Discussion

No community discussion yet for this question.

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