Interview Prep/Terraform/Testing Upgrades and Large-Scale Operations

What does each of `terraform validate`, `plan` and `terraform test` actually check?

BeginnerScenarioTesting Upgrades and Large-Scale Operations
Answer

Situation read → A team thinks validate means the config works.

What I'd do →

  1. validate: syntax, types and references only; no cloud calls, no provider credentials.
  2. plan: computes the real diff against state and the cloud; catches invalid values the API rejects at plan time.
  3. terraform test: runs .tftest.hcl files with assertions against plan or apply results.

Why → They're layers: structure, behaviour against reality, and behaviour you assert.

Interview tip → Many API errors only appear on apply (quotas, IAM), so plan isn't proof.

All Terraform questions Roadmap: Terraform in production

More on Testing Upgrades and Large-Scale Operations