terraform
config_error
ai_generated
true
错误:无效的 required_providers 块:重复的 required_providers 块
Error: Invalid required_providers block: duplicate required_providers block
ID: terraform/invalid-required-providers-block
95%修复率
84%置信度
1证据数
2023-09-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.5.0 | active | — | — | — |
| 1.6.0 | active | — | — | — |
| 1.7.0 | active | — | — | — |
根因分析
同一模块中存在多个 required_providers 块,这是 Terraform 不允许的。
English
Multiple required_providers blocks exist in the same module, which Terraform does not allow.
官方文档
https://developer.hashicorp.com/terraform/language/providers/requirements解决方案
-
将所有提供者需求合并到根模块中的单个 required_providers 块中。删除任何重复的块。
-
如果使用 Terraform 1.5+,在单个块中使用 'required_providers' 属性,合并所有条目。
无效尝试
常见但无效的做法:
-
90% 失败
Merging the blocks with incorrect syntax still results in a duplicate block error.
-
80% 失败
Adding a required_providers block inside a submodule does not fix the root module; the error is per module.