英文:
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
这是错误消息的重要部分。
- 您请求的版本大于或等于2.0.0
- 您偏好版本3.27
- 您偏好版本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
- You request a version greater than or equal to 2.0.0
- You prefer a version 3.27
- 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论