Interview Prep/Terraform/Workflow and Providers

You have dev, stage and prod using the same code but different sizes and counts. How do you feed per-environment values?

BeginnerScenarioWorkflow and Providers
Answer

Situation read → Same code, different inputs.

What I'd do →

  1. Keep one variables.tf with sensible defaults.
  2. Create envs/dev.tfvars, envs/stage.tfvars, envs/prod.tfvars.
  3. Run with terraform plan -var-file=envs/prod.tfvars, combined with a separate backend key per environment.

Why → Values are data, not code; the code path is identical across environments, which is what makes promotion trustworthy.

Interview tip → Pair the tfvars file with its own state, otherwise a -var-file mix-up can plan prod values into dev state.

All Terraform questions Roadmap: Terraform

More on Workflow and Providers