Provisioners run scripts or commands on resources after creation, but they can fail unpredictably and cause Terraform runs to be unreliable. This makes infrastructure harder to manage and maintain, so they are recommended only when no other options exist.
Using cloud-init or configuration management tools like Ansible or Chef integrated with the resource is more reliable and maintainable than provisioners. These tools handle configuration during resource creation or boot time.
If a provisioner fails, Terraform marks the resource as tainted, meaning it will be destroyed and recreated on the next apply. The apply process stops to prevent inconsistent state.
Provisioners often run scripts that may contain sensitive information like passwords or keys. These can be exposed in logs or error messages, creating security risks.
Provisioners should only be used when no other Terraform resource or external tool can perform the needed configuration. They are a last resort due to their unreliability and complexity.