terraform
type_error
ai_generated
true
Error: Invalid output value: output value type mismatch
ID: terraform/invalid-output-value-type
85%Fix Rate
83%Confidence
1Evidence
2023-04-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Terraform v1.0+ | active | — | — | — |
Root Cause
An output value's declared type does not match the actual type of the expression result.
generic中文
输出值的声明类型与表达式结果的实际类型不匹配。
Official Documentation
https://developer.hashicorp.com/terraform/language/values/outputs#type-constraintsWorkarounds
-
95% success Correct the type declaration to match the expression: e.g., change type = string to type = list(string) if output is a list
Correct the type declaration to match the expression: e.g., change type = string to type = list(string) if output is a list
-
85% success Use tostring(), tolist(), etc. to convert the value to the declared type
Use tostring(), tolist(), etc. to convert the value to the declared type
中文步骤
修正类型声明以匹配表达式:例如,如果输出是列表,将 type = string 改为 type = list(string)
使用 tostring()、tolist() 等函数将值转换为声明的类型
Dead Ends
Common approaches that don't work:
-
50% fail
Without type constraint, output may still fail if used elsewhere expecting a specific type.
-
70% fail
Hides the type mismatch but may cause downstream failures.