terraform module_error ai_generated true

错误:冲突的提供程序版本约束:多个模块要求提供程序 X 的不同版本

Error: Conflicting provider version constraints: multiple modules require different versions of provider X

ID: terraform/conflicting-provider-version-constraints

其他格式: JSON · Markdown 中文 · English
85%修复率
88%置信度
1证据数
2023-08-10首次发现

版本兼容性

版本状态引入弃用备注
Terraform >=1.3 active — — —
AzureRM Provider 3.x active — — —
AWS Provider 5.x active — — —

根因分析

配置中的两个或多个模块为同一提供程序指定了不兼容的版本约束,导致 Terraform 依赖解析失败。

English

Two or more modules in the configuration specify incompatible version constraints for the same provider, causing Terraform to fail dependency resolution.

generic

官方文档

https://developer.hashicorp.com/terraform/language/providers/requirements#version-constraints

解决方案

  1. 在所有模块中对齐版本约束。例如,在根模块设置 `required_providers { aws = "~> 5.0" }`,并确保所有子模块使用 `aws = ">= 5.0, < 6.0"`。
  2. 使用 `terraform providers` 检查版本要求,然后将约束更新为公共范围,例如在所有模块中使用 `version = "~> 5.0"`。

无效尝试

常见但无效的做法:

  1. 55% 失败

    Terraform may default to the latest provider version, which could be incompatible with existing state or resources.

  2. 75% 失败

    The lock file is managed by Terraform and manual edits are not preserved; also risks provider corruption.