Move a team from Terraform 0.13 / old provider versions to current versions. How do you avoid breaking things?

AdvancedScenarioMigrations
Answer

Situation read → Big jumps in Terraform and provider versions change state formats and resource schemas. Go step by step and read the upgrade guides.

What I'd do →

  1. Upgrade Terraform core in steps through 1.x (state format upgrades are one way), running plan at each step to confirm no changes.
  2. Pin providers with required_providers and commit .terraform.lock.hcl.
  3. Upgrade the AWS provider one major at a time, following the upgrade guide (for example, v4 split aws_s3_bucket into separate resources; v5 and v6 removed deprecated arguments).
  4. Refactor with moved blocks or import blocks instead of letting Terraform destroy and recreate.
moved {
  from = aws_s3_bucket.logs
  to   = module.logging.aws_s3_bucket.this
}
  1. Back up state before each step; S3 versioning gives you this.

Why → A clean "no changes" plan after every step is the only proof the upgrade is safe.

Interview tip → Mention moved and import blocks; they replace error-prone terraform state mv commands.

All Real-World Interview questions Roadmap: Interview readiness

More on Migrations