Environments for Terraforms
Environments in Terraform deal with running the same infrastructure code for dev, staging and production. Two common approaches are workspaces, which keep multiple state files for one configuration, and separate directories or repositories per environment with shared modules. Choosing a layout affects blast radius, access control and how much duplication you accept.
Stage: State · Part of the Terraform roadmap · Last reviewed 19 November 2026
What to learn in Environments
- Create and switch Terraform workspaces and see how state is separated
- Pass environment-specific values using tfvars files
- Compare workspaces with separate directories for environment isolation
- Limit blast radius by splitting large configurations into smaller stacks
- Share outputs between configurations using remote state data or outputs
Environments interview questions
When are Terraform workspaces a poor choice for environments?
Workspaces share the same code and backend, so they give little isolation: a mistake in the selected workspace can hit production, and permissions are hard to separate. Teams needing strict separation of access or different configurations often use separate directories and backends.
What is blast radius in infrastructure code?
Blast radius is how much could be affected if a change goes wrong. A single huge configuration for everything means one bad apply can touch many systems. Splitting into smaller stacks by environment and component limits the damage and speeds up plans.
Where Environments fits in the Terraform roadmap
Environments belongs to the State stage (intermediate level), which takes about 12 hours. Source of truth.
Other units in this stage
Back to the full Terraform roadmap