terraform
type_error
ai_generated
true
错误:无效的输出值:输出值类型不匹配
Error: Invalid output value: output value type mismatch
ID: terraform/invalid-output-value-type
85%修复率
83%置信度
1证据数
2023-04-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Terraform v1.0+ | active | — | — | — |
根因分析
输出值的声明类型与表达式结果的实际类型不匹配。
English
An output value's declared type does not match the actual type of the expression result.
官方文档
https://developer.hashicorp.com/terraform/language/values/outputs#type-constraints解决方案
-
修正类型声明以匹配表达式:例如,如果输出是列表,将 type = string 改为 type = list(string)
-
使用 tostring()、tolist() 等函数将值转换为声明的类型
无效尝试
常见但无效的做法:
-
50% 失败
Without type constraint, output may still fail if used elsewhere expecting a specific type.
-
70% 失败
Hides the type mismatch but may cause downstream failures.