Interview Prep/CI/CD/Secrets and Credentials

How do you secure Terraform pipelines that need powerful cloud permissions?

AdvancedProductionSecrets and Credentials
Answer

Split roles: a read-only role for terraform plan on PRs (also usable by untrusted contributors via a plan-only workflow), and an apply role assumable only from the protected main workflow with environment approval. Use remote state with encryption, locking and restricted access (state contains secrets), pin providers with the lock file, run plan output through policy checks (Conftest/OPA) and require review of the plan before apply, and give the apply role permissions boundaries so it cannot grant itself admin.

All CI/CD questions

More on Secrets and Credentials