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…
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)- B7% (1)
- C93% (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
Community Discussion
No community discussion yet for this question.