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.
More on CI/CD and Automation
Why run Terraform from a pipeline instead of laptops?BeginnerWhat stages does a good Terraform pull-request pipeline have?BeginnerHow do you make sure the apply runs exactly what was reviewed?IntermediateHow do you serialize applies to the same stack in CI?AdvancedShow a minimal GitHub Actions workflow for plan on PR.BeginnerHow does OIDC authentication from GitHub Actions to AWS work?Intermediate