Interview Prep/Terraform/Secrets Provisioners and Policy as Code

Someone wants a `remote-exec` provisioner to configure servers after creation. What's your advice?

BeginnerScenarioSecrets Provisioners and Policy as Code
Answer

Situation read → Provisioners are a last resort.

What I'd do →

  1. Prefer user_data/cloud-init for first boot and baked AMIs (Packer) for software.
  2. Use Ansible or SSM State Manager for configuration management.
  3. If you must use a provisioner, make it idempotent and set on_failure.

Why → Provisioners don't appear in plan, aren't tracked by state, need network access to the host and fail halfway, leaving tainted resources. HashiCorp documents them as a last resort.

Interview tip → Know local-exec vs remote-exec and why neither is declarative.

All Terraform questions

More on Secrets Provisioners and Policy as Code