Provisioner Failure Behavior in Terraform
📖 Scenario: You are managing cloud infrastructure using Terraform. Sometimes, when Terraform runs a provisioner script on a resource, the script might fail. You want to control what happens when this failure occurs.Terraform allows you to specify how it should behave if a provisioner fails, using the on_failure setting.
🎯 Goal: Build a Terraform configuration that creates a simple resource with a local-exec provisioner. Configure the provisioner to handle failure by choosing the on_failure behavior.You will create the resource, add the provisioner, and set the failure behavior to continue.
📋 What You'll Learn
Create a Terraform resource of type
null_resource named exampleAdd a
local-exec provisioner that runs the command exit 1 (which will fail)Add the
on_failure argument to the provisioner and set it to continue💡 Why This Matters
🌍 Real World
In real cloud infrastructure, provisioners run scripts or commands on resources after creation. Sometimes these scripts fail, and you need to decide if Terraform should stop or continue.
💼 Career
Understanding provisioner failure behavior helps cloud engineers manage infrastructure deployments reliably and avoid unexpected interruptions.
Progress0 / 4 steps