RPROSHAN PRASADENGINEERING NOTES
All articles
Terraform

A Safer Workflow for Terraform Infrastructure Changes

A practical workflow for reviewing plans, isolating environments, protecting state, and making infrastructure changes repeatable in CI/CD.

TerraformAWSCI/CD

Treat infrastructure changes like application changes

Terraform makes infrastructure repeatable, but a successful command is not proof that a change is safe. Use version control, peer review, a plan review, and a controlled apply process.

A simple workflow

Keep reusable modules separate from environment-specific configuration and avoid sharing state between unrelated environments.

  • Format and validate the configuration.
  • Run a plan against the intended workspace or backend.
  • Review creates, updates, replacements, and deletions.
  • Apply only an approved plan using controlled credentials.
  • Verify the deployed resources and record the outcome.
terraform fmt -check
terraform init
terraform validate
terraform plan -out=tfplan

Protect state and credentials

Use a remote backend with access controls, encryption, and state locking where supported. Never commit state files, credentials, or sensitive plan output to a public repository. Prefer short-lived workload identity or role-based credentials in CI/CD.

SRE takeaway

A good infrastructure pipeline makes changes reviewable, reversible where possible, and observable after deployment. Treat destructive replacements as explicit risk decisions rather than routine plan output.