How do you review a PR that adds a `local-exec` provisioner?
IntermediateScenarioSecrets Provisioners and Policy as Code
Answer
Situation read → Arbitrary code runs on the CI runner with deployment credentials.
What I'd do →
- Ask why no provider or data source can do it.
- Read the script: idempotent? quoting safe? no secret in command line (visible in process list and logs)?
- Check failure behaviour (
on_failure) and that destroy-time behaviour is handled. - Require a ticket to retire it when native support exists.
Why → Provisioners run outside Terraform's model, so the review must cover the script as if it were production code.
Interview tip → Mention injection risk if interpolating untrusted variables into commands.
More on Secrets Provisioners and Policy as Code
A developer hardcodes a DB password in `terraform.tfvars` and commits it. What do you do right now, and what's the long-term fix?BeginnerHow do you avoid Terraform persisting a secret in state when creating a secret in AWS Secrets Manager?AdvancedSomeone wants a `remote-exec` provisioner to configure servers after creation. What's your advice?BeginnerYou must run a one-off command after a resource is created, such as registering with an external system.IntermediateHow do you generate and manage the master password for a new RDS instance?IntermediateCompare Sentinel, OPA/Conftest and Checkov for policy as code.Intermediate