Reputation: 65
I am not sure how to resolve this error, tried various combination of versions but can not get this working;
Within my modules:
terraform {
required_version = "~> 1.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 2.98.0". #or 2.62.1 ,1.6.0 depending on the what resource the module is for
}
}
}
Within my main.tf file:
terraform {
required_version = "~> 1.0.1"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
}
azuread = {
source = "hashicorp/azuread"
}
external = {
source = "hashicorp/external"
}
random = {
source = "hashicorp/random"
}
sops = {
source = "carlpett/sops"
}
}
}
Error upon terraform init:
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/azurerm: locked provider registry.terraform.io/hashicorp/azurerm 2.56.0 does not match
│ configured version constraint ~> 2.62.1, ~> 2.98.0; must use terraform init -upgrade to allow selection of new versions
╵
This is providers requirements.
user:$ terraform providers
Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/random]
├── provider[registry.terraform.io/carlpett/sops] 0.6.3
├── provider[registry.terraform.io/hashicorp/azurerm]
├── provider[registry.terraform.io/hashicorp/azuread] ~> 1.6.0
├── provider[registry.terraform.io/hashicorp/external]
├── module.azurerm_storagecontainer_container1
│ └── provider[registry.terraform.io/hashicorp/azurerm] ~> 2.98.0
├── module.azurerm_servicebusqueue_bus1
│ └── provider[registry.terraform.io/hashicorp/azurerm] ~> 2.62.1
├── module.azurerm_storageaccount
│ ├── provider[registry.terraform.io/hashicorp/random]
│ └── provider[registry.terraform.io/hashicorp/azurerm] ~> 2.98.0
├── module.azurerm_key_vault
│ ├── provider[registry.terraform.io/hashicorp/azurerm] ~> 2.98.0
│ └── provider[registry.terraform.io/hashicorp/azuread]
├── module.resourcegroup
│ └── provider[registry.terraform.io/hashicorp/azurerm] ~> 2.98.0
Providers required by state:
provider[registry.terraform.io/hashicorp/azuread]
provider[registry.terraform.io/hashicorp/azurerm]
provider[registry.terraform.io/hashicorp/random]
provider[registry.terraform.io/carlpett/sops]
Upvotes: 2
Views: 4944
Reputation: 65
So the issue was one of the module dependency "servicebus" was still using older version for azurerm which cause this failure. so I updated it to 2.98.0 and that got me going. Earlier I thought that would not matter different module can have different azurerm version but that assumption was wrong. In tf consumer make sure that all module dependency should use same provide version.
Upvotes: 3