How do you manage multiple environments in Terraform?

Answer

Multiple environment strategies in Terraform: Directory-per-environment (recommended): separate directories envs/dev/main.tf, envs/prod/main.tf. Each calls shared modules with different variables. Each environment has its own state file. Strong isolation — a mistake in dev never touches prod state. Workspaces: single config, multiple state files. Simpler but risk of one codebase affecting all environments. Best for short-lived environments. Terragrunt environment hierarchy: parent terragrunt.hcl with DRY backend config; each env folder overrides variables. Scales well for many environments and regions. Variable overrides: use *.auto.tfvars files per environment loaded based on workspace or CLI flags. The directory-per-environment approach is the most robust for production systems because it provides full isolation of state and can use different IAM credentials per environment, preventing accidents.