terraform
state_error
ai_generated
true
Error: Workspace not found: the workspace does not exist
ID: terraform/tf-workspace-not-found
92%Fix Rate
93%Confidence
55Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1 | active | — | — | — |
Root Cause
Terraform workspace referenced in configuration or CLI does not exist in the backend.
genericWorkarounds
-
92% success Create the missing workspace using terraform workspace new
terraform workspace new WORKSPACE_NAME
Sources: https://developer.hashicorp.com/terraform/cli/commands/workspace/new
-
90% success Switch to an existing workspace using terraform workspace select
terraform workspace list to see available workspaces, then terraform workspace select WORKSPACE_NAME
Sources: https://developer.hashicorp.com/terraform/cli/commands/workspace/select
Dead Ends
Common approaches that don't work:
-
Edit the .terraform/environment file to force-set the workspace
80% fail
If the workspace does not exist in the backend, manually setting the file creates an invalid state
-
Use terraform.workspace in conditions without creating the workspace first
75% fail
References to terraform.workspace assume the workspace exists; plan fails if it does not
Error Chain
Preceded by: