# 错误：变量默认值中存在无效插值：此处不能使用变量

- **ID:** `terraform/invalid-interpolation-in-variable-default`
- **领域:** terraform
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

Terraform 变量在其默认值中不能引用其他变量，默认值必须是字面值。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.5.0 | active | — | — |
| 1.6.0 | active | — | — |
| 1.7.0 | active | — | — |

## 解决方案

1. ```
   将变量引用替换为字面值，或使用 local 值在变量声明后计算默认值。
   ```
2. ```
   定义一个无默认值的单独变量，并使用 locals 块根据其他变量设置默认值。
   ```

## 无效尝试

- **** — Adding escape characters or quotes around the interpolation does not resolve the fundamental limitation. (95% 失败率)
- **** — Moving the interpolation to a locals block still fails because the variable default is evaluated before locals are available. (80% 失败率)
