nerdexam
HashiCorp

TA-002-P · Question #361

If a Terraform creation-time provisioner fails, what will occur by default?

The correct answer is C. The resource will be marked as "tainted". When a creation-time provisioner fails, Terraform marks the resource as 'tainted' by default. A tainted resource is one that Terraform knows was created but may not be configured correctly. On the next terraform apply, Terraform will destroy the tainted resource and recreate it…

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

Question

If a Terraform creation-time provisioner fails, what will occur by default?

Options

  • AThe resource will not be affected, but the provisioner will need to be applied again
  • BThe resource will be destroyed
  • CThe resource will be marked as "tainted"
  • DNothing, provisioners will not show errors in the command line

How the community answered

(15 responses)
  • B
    7% (1)
  • C
    93% (14)

Explanation

When a creation-time provisioner fails, Terraform marks the resource as 'tainted' by default. A tainted resource is one that Terraform knows was created but may not be configured correctly. On the next terraform apply, Terraform will destroy the tainted resource and recreate it from scratch, re-running the provisioner. This behavior can be overridden using on_failure = continue in the provisioner block, which will ignore errors. The resource is NOT destroyed immediately - it stays in state as tainted. Answer C is correct.

Topics

#provisioners#error handling#resource lifecycle#taint

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice