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

其他格式: JSON · Markdown 中文 · English
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.

generic

官方文档

https://developer.hashicorp.com/terraform/language/providers/requirements

解决方案

  1. 将所有提供者需求合并到根模块中的单个 required_providers 块中。删除任何重复的块。
  2. 如果使用 Terraform 1.5+,在单个块中使用 'required_providers' 属性,合并所有条目。

无效尝试

常见但无效的做法:

  1. 90% 失败

    Merging the blocks with incorrect syntax still results in a duplicate block error.

  2. 80% 失败

    Adding a required_providers block inside a submodule does not fix the root module; the error is per module.