nerdexam
HashiCorp

TERRAFORM-ASSOCIATE-004 · Question #263

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

The correct answer is D. the resource is marked as tainted. If a Terraform resource is successfully created but then fails during its provisioning stage, the resource is marked as 'tainted' in the state file.

Submitted by jakub_pl· Apr 18, 2026Understand Terraform Basics

Question

During a terraform apply, 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
  • Bit is automatically deleted
  • Cthe terraform plan is rolled back and all provisioned resources are removed
  • Dthe resource is marked as tainted

How the community answered

(44 responses)
  • A
    5% (2)
  • C
    2% (1)
  • D
    93% (41)

Why each option

If a Terraform resource is successfully created but then fails during its provisioning stage, the resource is marked as 'tainted' in the state file.

ATerraform attempts to provision the resource up to three times before exiting with an error

Terraform does not automatically retry resource provisioning attempts; upon failure, the resource is marked as tainted, requiring manual intervention or a subsequent apply.

Bit is automatically deleted

Terraform does not automatically delete a resource that failed during provisioning; instead, it marks the resource as tainted so it can be re-evaluated and potentially replaced on the next apply.

Cthe terraform plan is rolled back and all provisioned resources are removed

Terraform does not automatically roll back an entire plan or remove all provisioned resources if a single resource's provisioner fails; only the failed resource is marked as tainted.

Dthe resource is marked as taintedCorrect

If a resource is successfully created but its associated provisioner fails, Terraform marks that resource as 'tainted' in the state file, signaling that it is in an inconsistent state and will be destroyed and recreated on the subsequent `terraform apply`.

Concept tested: Terraform resource provisioning failure

Source: https://developer.hashicorp.com/terraform/language/resources/provisioners/syntax#failure-behavior

Topics

#Terraform apply#Resource lifecycle#Tainted resources#Error handling

Community Discussion

No community discussion yet for this question.

Full TERRAFORM-ASSOCIATE-004 Practice