Manage multiple Terraform state workspaces for environment isolation.
medium risk
Terraform workspaces maintain separate state files for the same configuration, enabling environment isolation (dev/staging/prod) without duplicating code. Each workspace has its own state. The current workspace name is accessible via `terraform.workspace`.
terraform workspace listList all workspaces (* marks current) · explain & risk-check →terraform workspace new stagingCreate a new staging workspace · explain & risk-check →terraform workspace select productionSwitch to production workspace · explain & risk-check →terraform workspace showDisplay current workspace name · explain & risk-check →terraform plan -var-file=${terraform workspace show}.tfvarsUse workspace name to select var file · explain & risk-check →Always run `terraform workspace show` before plan/apply in production — verify you're in the right workspace before making changes. Add it to your pre-apply checklist.
Reference text is hand-written and may be incomplete — check man terraform for your version. Test destructive commands on a non-production system first.