Terraform: 解决 “没有可用的发布版本与给定的约束条件匹配” 错误。

huangapple go评论62阅读模式
英文:

Terraform: resolve "no available releases match the given constraints" error

问题

我正在尝试更新 hashicorp/aws 提供程序的版本。

我添加了 terraform.tf 文件,内容如下:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.0"
    }
  }
}

后来我尝试使用以下命令更新模块:

terraform init -upgrade

然而,我开始收到以下错误消息:

Could not retrieve the list of available versions for provider hashicorp/aws: no available releases match the given constraints >= 2.0.0, ~> 3.27, ~> 4.0

如何解决这个问题?

英文:

I am trying to update hashicorp/aws provider version.

I added terraform.tf file with following content:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.0"
    }
  }
}

Later I tried to update modules using:

terraform init -upgrade

However, I have started to get:

Could not retrieve the list of available versions for provider hashicorp/aws: no available releases match the given constraints >= 2.0.0, ~> 3.27, ~> 4.0

How could this problem be resolved?

答案1

得分: 2

这是错误消息的重要部分。

  1. 您请求的版本大于或等于2.0.0
  2. 您偏好版本3.27
  3. 您偏好版本4.0

2和3不能同时成立。

解决此特定情况的方法是停止同时请求2个不同的版本。

检查可用提供程序的版本:

!+?main ~/Projects/x/src/x-devops/terraform/env/test> terraform providers

配置所需的提供程序:
。
├── module.test-sonar
│   └── provider[registry.terraform.io/hashicorp/aws]
├── module.client_vpn
│   └── provider[registry.terraform.io/hashicorp/aws]
├── module.test-appserver
│   └── provider[registry.terraform.io/hashicorp/aws] ~> 3.27
├── module.test-vpn-server
│   └── provider[registry.terraform.io/hashicorp/aws]
├── module.test-networking
...

有一个模块请求 3.27

查找所有请求 3.27 的模块并将它们更新为 4.0

这应该解决这类问题。

英文:

This is the important part of the error message.

>= 2.0.0, ~> 3.27, ~> 4.0
  1. You request a version greater than or equal to 2.0.0
  2. You prefer a version 3.27
  3. You prefer a version 4.0

Both 2 and 3 cannot be possible at the same time.

The solution for this specific case is the stop requesting 2 different versions at the same time.

Check versions of available providers:

!+?main ~/Projects/x/src/x-devops/terraform/env/test> terraform providers

Providers required by configuration:
.
├── module.test-sonar
│   └── provider[registry.terraform.io/hashicorp/aws]
├── module.client_vpn
│   └── provider[registry.terraform.io/hashicorp/aws]
├── module.test-appserver
│   └── provider[registry.terraform.io/hashicorp/aws] ~> 3.27
├── module.test-vpn-server
│   └── provider[registry.terraform.io/hashicorp/aws]
├── module.test-networking
...

There is a module which requests 3.27.

Find all modules which request 3.27 and update them to 4.0.

This should resolve such problems.

huangapple
  • 本文由 发表于 2023年5月17日 20:28:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76272116.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定