Interview Prep/Terraform/Workflow and Providers

How do you make sure nobody runs your code with a Terraform version it wasn't tested against?

BeginnerScenarioWorkflow and Providers
Answer

Situation read → Different CLI versions can rewrite state in incompatible ways.

What I'd do →

  1. Set required_version in the terraform block.
  2. Pin the CLI in CI with hashicorp/setup-terraform or a .terraform-version file for tfenv/mise.
terraform {
  required_version = "~> 1.9.0"
}

Why → Once a newer Terraform writes state, older versions refuse to read it. Pinning avoids a surprise "state was created by a newer version" for the rest of the team.

Interview tip → Upgrade the CLI as a deliberate change, one environment at a time.

All Terraform questions Roadmap: Terraform

More on Workflow and Providers