terraform
config_error
ai_generated
true
Error: Invalid workspace name: Workspace names must start with a letter and may contain only letters, digits, underscores, and hyphens. Name "my workspace" is invalid.
ID: terraform/invalid-terraform-workspace-name
100%Fix Rate
90%Confidence
1Evidence
2023-06-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Terraform v1.5 | active | — | — | — |
| Terraform v1.6 | active | — | — | — |
| Terraform v1.7 | active | — | — | — |
Root Cause
The workspace name contains spaces or special characters that violate Terraform's naming rules for workspaces.
generic中文
工作区名称包含空格或特殊字符,违反了 Terraform 对工作区的命名规则。
Official Documentation
https://developer.hashicorp.com/terraform/cli/commands/workspace/newWorkarounds
-
100% success Use underscore or hyphen instead of space: 'terraform workspace new my_workspace' or 'terraform workspace new my-workspace'. This is the only valid approach.
Use underscore or hyphen instead of space: 'terraform workspace new my_workspace' or 'terraform workspace new my-workspace'. This is the only valid approach.
中文步骤
Use underscore or hyphen instead of space: 'terraform workspace new my_workspace' or 'terraform workspace new my-workspace'. This is the only valid approach.
Dead Ends
Common approaches that don't work:
-
95% fail
Shell escaping doesn't change the workspace name stored in Terraform; the name itself is invalid regardless of how it's passed.
-
90% fail
Quotes only prevent shell splitting; Terraform still validates the name and rejects spaces.
-
85% fail
The environment variable is used to select an existing workspace, not to create one. The name validation still applies.