Skip to main content
When using provisioners in Terraform, keep in mind several important caveats. Provisioners can be convenient for short-lived or experimental tasks, but they introduce operational risks that make them inappropriate for most production workloads.

Key concerns

  1. Idempotency
  • Provisioner scripts are often non-idempotent unless you explicitly design them to be. Terraform does not enforce idempotency for arbitrary scripts. Re-running Terraform or recreating a resource can cause a provisioner to:
    • reinstall software,
    • duplicate configuration,
    • overwrite or corrupt existing state,
    • or fail unexpectedly during re-execution.
  1. Failure handling and recoverability
  • If a provisioner fails partway through, Terraform provides limited retry logic and no automatic rollback. This can leave resources partially configured and difficult to audit or recover. Embedding ad-hoc scripts in Terraform also reduces centralized reporting and versioned configuration tracking compared to dedicated configuration management tools.
The image is a table highlighting why something is not recommended for production, listing risks/issues like non-idempotency and difficulties with management, alongside their impacts such as unpredictable failures and lack of central management.
  1. Tight coupling to Terraform
  • Putting configuration logic inside Terraform runs mixes infrastructure provisioning with configuration management. This tight coupling reduces modularity, makes testing and reuse harder, and blurs separation of concerns between infrastructure and configuration.
Because of these issues, provisioners should be used sparingly and only when there is no practical alternative.
The image lists reasons why something is not recommended for production, highlighting risks such as non-idempotency and close coupling to Terraform, along with related issues like unpredictability and lack of modularity.

Summary of risks

Best practices

  • Use provisioners only for temporary, non-critical, or development/test automation (quick setup tasks, proof-of-concepts, lightweight initialization).
  • Keep provisioner scripts small and make them idempotent whenever possible.
  • Avoid embedding complex configuration logic in Terraform; do not use provisioners for ongoing configuration management.
For production workloads, prefer platform-native or dedicated configuration solutions that support idempotency, lifecycle integration, and centralized reporting: These approaches provide better operational reliability, idempotency, and lifecycle management than ad-hoc provisioner scripts.
Provisioners are a last resort. For repeatable, auditable, and reliable configuration, prefer platform-native extensions, configuration management tools, or image-based pipelines over Terraform provisioners.
In short: use provisioners sparingly, keep them simple and idempotent, and prefer built-in configuration management or platform-native solutions for production systems. With that, we have completed the provisioners section.

Watch Video

Practice Lab