terraform
config_error
ai_generated
true
错误:无效的 Terraform 版本约束
Error: Invalid terraform version constraint
ID: terraform/invalid-terraform-version-constraint
90%修复率
85%置信度
1证据数
2023-03-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Terraform v1.4.0+ | active | — | — | — |
| OpenTofu 1.6.0 | active | — | — | — |
根因分析
terraform 块中的 required_version 设置使用了不支持的运算符或格式错误的版本字符串。
English
The required_version setting in terraform block uses an unsupported operator or malformed version string.
官方文档
https://developer.hashicorp.com/terraform/language/settings#specifying-a-required-terraform-version解决方案
-
使用有效的约束语法:required_version = ">= 1.4.0, < 2.0.0"
-
使用悲观约束运算符:required_version = "~> 1.5"
无效尝试
常见但无效的做法:
-
60% 失败
Comma is not a valid operator; Terraform expects space-separated constraints like '>= 1.0, < 2.0' is actually invalid, must use '>= 1.0, < 2.0' without comma or use '~>' operator.
-
40% 失败
The '=' operator is not supported; Terraform interprets bare numbers as pessimistic constraint operator '~>'.