# 错误：无效的工作区名称：工作区名称必须以字母开头，且只能包含字母、数字、下划线和连字符。名称 "my workspace" 无效。

- **ID:** `terraform/invalid-terraform-workspace-name`
- **领域:** terraform
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 100%

## 根因

工作区名称包含空格或特殊字符，违反了 Terraform 对工作区的命名规则。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Terraform v1.5 | active | — | — |
| Terraform v1.6 | active | — | — |
| Terraform v1.7 | active | — | — |

## 解决方案

1. ```
   Use underscore or hyphen instead of space: 'terraform workspace new my_workspace' or 'terraform workspace new my-workspace'. This is the only valid approach.
   ```

## 无效尝试

- **** — Shell escaping doesn't change the workspace name stored in Terraform; the name itself is invalid regardless of how it's passed. (95% 失败率)
- **** — Quotes only prevent shell splitting; Terraform still validates the name and rejects spaces. (90% 失败率)
- **** — The environment variable is used to select an existing workspace, not to create one. The name validation still applies. (85% 失败率)
