Terraform downloads the deprecated azure provider

December 20, 2022 

You are 100% sure that all your Terraform resources are using terraform-provider-azurerm, yet Terraform attempts to download the deprecated "azure" provider:

$ terraform init
Initializing modules...

Initializing the backend...

Initializing provider plugins...
- Finding hashicorp/local versions matching "2.2.3"...
- Finding latest version of hashicorp/azure...
- Finding hashicorp/azurerm versions matching "3.17.0"...
- Installing hashicorp/local v2.2.3...
- Installed hashicorp/local v2.2.3 (signed by HashiCorp)
- Installing hashicorp/azurerm v3.17.0...
- Installed hashicorp/azurerm v3.17.0 (signed by HashiCorp)
╷
│ Error: Failed to query available provider packages
│ 
│ Could not retrieve the list of available versions for provider hashicorp/azure: provider registry registry.terraform.io does not have a provider named
│ registry.terraform.io/hashicorp/azure
│ 
│ Did you intend to use terraform-providers/azure? If so, you must specify that source address in each module which requires that provider. To see which
│ modules are currently depending on hashicorp/azure, run the following command:
│     terraform providers
╵

You grep the state file and find no references to the "azure" provider. You assume that the cause is some nested module that depends on it, but no, that's not it. You run "terraform providers" and see that indeed, the "azure" provider is required:

$ terraform providers

Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/local] 2.2.3
├── provider[registry.terraform.io/hashicorp/azurerm] 3.17.0
├── provider[registry.terraform.io/hashicorp/azure]
└── module.automation
    ├── provider[registry.terraform.io/hashicorp/azurerm]
    └── provider[registry.terraform.io/hashicorp/local]

Providers required by state:

    provider[registry.terraform.io/hashicorp/azurerm]

    provider[registry.terraform.io/hashicorp/local]

At this point you become desperate: if you did not explicitly define the "azure" provider anywhere, why is it haunting you? Then you notice that there's a typo in one of your resources:

resource "azure_private_dns_zone" "internal_example_org" {
  name                = "internal.example.org"
  resource_group_name = azurerm_resource_group.default.name
}

Indeed: "azure_private_dns_zone" instead of "azurerm_private_dns_zone". That is all it takes for Terraform's dynamic provider dependency loading magic to break things for you in a way that is not immediately obvious.

Hopefully this helps some other poor soul who accidentally types "azure" instead of "azurerm".

Samuli Seppänen
Samuli Seppänen
Author archive
menucross-circle