terraform
config_error
ai_generated
true
错误:无效的工作区名称:工作区名称必须以字母开头,且只能包含字母、数字、下划线和连字符。名称 "my workspace" 无效。
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%修复率
90%置信度
1证据数
2023-06-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Terraform v1.5 | active | — | — | — |
| Terraform v1.6 | active | — | — | — |
| Terraform v1.7 | active | — | — | — |
根因分析
工作区名称包含空格或特殊字符,违反了 Terraform 对工作区的命名规则。
English
The workspace name contains spaces or special characters that violate Terraform's naming rules for workspaces.
官方文档
https://developer.hashicorp.com/terraform/cli/commands/workspace/new解决方案
-
Use underscore or hyphen instead of space: 'terraform workspace new my_workspace' or 'terraform workspace new my-workspace'. This is the only valid approach.
无效尝试
常见但无效的做法:
-
95% 失败
Shell escaping doesn't change the workspace name stored in Terraform; the name itself is invalid regardless of how it's passed.
-
90% 失败
Quotes only prevent shell splitting; Terraform still validates the name and rejects spaces.
-
85% 失败
The environment variable is used to select an existing workspace, not to create one. The name validation still applies.