Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to retrieve provider versions for hashicorp/azurerm in Module 03-Network-Hub (URGENT) #162

Open
upwardsolutions-inc opened this issue Jan 16, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@upwardsolutions-inc
Copy link

The issue occurs when running terraform init for the 03-Network-Hub module in the AKS Landing Zone Accelerator repository. The error specifically states that no provider versions match the given constraints for hashicorp/azurerm. However, the same issue is not encountered when initializing other modules like 04-Network-LZ or 06-AKS-Cluster.

Steps to Reproduce:

  1. Clone the AKS Landing Zone Accelerator repository.
  2. Navigate to the Scenarios/03-Network-Hub directory.
  3. Run the following command:
    terraform init
  4. Observe the error:
Error: Failed to query available provider packages
│ Could not retrieve the list of available versions for provider hashicorp/azurerm: 
│ no available releases match the given constraints >= 3.71.0, ~> 3.71, ~> 3.117, ~> 4.0, < 4.0.0, < 5.0.0
  1. Navigate to other modules such as 04-Network-LZ or 06-AKS-Cluster:
cd Scenarios/04-Network-LZ
terraform init
  1. Observe that no error occurs during initialization for these modules.

Expected Behavior:
Terraform should successfully initialize the 03-Network-Hub module without errors, similar to the other modules.

Actual Behavior:
Terraform fails to initialize the 03-Network-Hub module and outputs the following error:

Error: Failed to query available provider packages
│ Could not retrieve the list of available versions for provider hashicorp/azurerm: 
│ no available releases match the given constraints >= 3.71.0, ~> 3.71, ~> 3.117, ~> 4.0, < 4.0.0, < 5.0.0

Logs:
Attach Terraform debug logs (TF_LOG=TRACE terraform init) for the 03-Network-Hub module. Focus on any discrepancies in provider download attempts.

@upwardsolutions-inc upwardsolutions-inc added the bug Something isn't working label Jan 16, 2025
@upwardsolutions-inc
Copy link
Author

I found the root cause. In the main.tf file, the below code didn't specify the version and it was taking the latest version 0.4.0 which depends on azurerm ~> 4.0 which was conflicting with other modules which depends on azurerm ~> 3.x.

By adding the version line, fixes the issue.
version = "0.3.0"

module "azure_bastion" {
source = "Azure/avm-res-network-bastionhost/azurerm"
name = "bastion"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
copy_paste_enabled = true
file_copy_enabled = false
sku = "Standard"
ip_configuration = {
name = "bastion-ipconfig"
subnet_id = module.avm-res-network-virtualnetwork.subnets["AzureBastionSubnet"].resource_id
public_ip_address_id = module.publicIpBastion.public_ip_id
}
ip_connect_enabled = true
scale_units = 4
shareable_link_enabled = true
tunneling_enabled = true
kerberos_enabled = false
}

upwardsolutions-inc added a commit to upwardsolutions-inc/AKS-Landing-Zone-Accelerator that referenced this issue Jan 16, 2025
### Fix for Provider Version Conflict in 03-Network-Hub Module
This PR addresses the issue described in Azure#162, where the `azure_bastion` module causes a provider version conflict for `azurerm`. The conflict arises due to differing provider version constraints between the root module and the `Azure/avm-res-network-routetable/azurerm` module.

#### Changes Made:
1. Updated the `main.tf` in the root module to ensure consistent provider constraints by adding version attribute with the value 0.3.0:
   ```hcl
   
module "azure_bastion" {
  source = "Azure/avm-res-network-bastionhost/azurerm"
  version = "0.3.0"
  name                = "bastion"
  resource_group_name = azurerm_resource_group.rg.name
  location            = azurerm_resource_group.rg.location
  copy_paste_enabled  = true
  file_copy_enabled   = false
  sku                 = "Standard"
  ip_configuration = {
    name                 = "bastion-ipconfig"
    subnet_id            = module.avm-res-network-virtualnetwork.subnets["AzureBastionSubnet"].resource_id
    public_ip_address_id = module.publicIpBastion.public_ip_id
  }
  ip_connect_enabled     = true
  scale_units            = 4
  shareable_link_enabled = true
  tunneling_enabled      = true
  kerberos_enabled       = false
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants