Interview Prep/Terraform/CI/CD and Automation

Why separate plan and apply identities?

IntermediateProductionCI/CD and Automation
Answer

A plan role can be read-only (plus state read and lock), so PRs from branches (potentially untrusted) cannot change infrastructure. The apply role is write-capable and only assumable from the protected main branch or an approved environment. This limits the damage of a malicious PR, since Terraform config can run arbitrary code during plan via external data sources or provider config.

All Terraform questions Roadmap: Terraform in production

More on CI/CD and Automation