│ Error: Missing required provider

PS C:\Karthik\Velmurugan\Azure\Terraform\terraform-on-azure-cloud\terraform-on-azure-cloud-main\10-Azure-Virtual-Network-4Tier\terraform-manifests> terraform validate
╷
│ Error: Missing required provider
│
│ This configuration requires provider registry.terraform.io/hashicorp/azure, but that provider isn't available. 
│ You may be able to install it automatically by running:
│   terraform init
╵
╷
│ Error: Missing required provider
│
│ This configuration requires provider registry.terraform.io/hashicorp/azurerm, but that provider isn't
│ available. You may be able to install it automatically by running:
│   terraform init
╵
╷
│ Error: Missing required provider
│
│ This configuration requires provider registry.terraform.io/hashicorp/random, but that provider isn't
│ available. You may be able to install it automatically by running:
│   terraform init
╵
PS C:\Karthik\Velmurugan\Azure\Terraform\terraform-on-azure-cloud\terraform-on-azure-cloud-main\10-Azure-Virtual-Network-4Tier\terraform-manifests>
terraform version
Terraform v1.2.2
on windows_amd64
PS C:\Karthik\Velmurugan\Azure\Terrafor# Terraform Block
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = ">= 2.0" 
    }
    random = {
      source = "hashicorp/random"
      version = ">= 3.0"
    }
  }
}

# Provider Block
provider "azurerm" {
 features {}          
}

Hi @karthikeyaon.da,

The first command you ran, terraform validate, first requires that all providers are installed in order to fetch all the necessary schemas, which is why the error suggests running terraform init. Did you try running that command as well?

Yes I ran terraform validate and getting this error

PS C:\Karthik\Velmurugan\Azure\Terraform\terraform-on-azure-cloud\terraform-on-azure-cloud-main\10-Azure-Virtual-Network-4Tier\terraform-manifests> terraform validate

│ Error: Missing required provider

│ This configuration requires provider Terraform Registry, but that provider isn’t available.
│ You may be able to install it automatically by running:
│ terraform init


│ Error: Missing required provider

│ This configuration requires provider Terraform Registry, but that provider isn’t
│ available. You may be able to install it automatically by running:
│ terraform init


│ Error: Missing required provider

│ This configuration requires provider Terraform Registry, but that provider isn’t
│ available. You may be able to install it automatically by running:
│ terraform init

PS C:\Karthik\Velmurugan\Azure\Terraform\terraform-on-azure-cloud\terraform-on-azure-cloud-main\10-Azure-Virtual-Network-4Tier\terraform-manifests>

The command you need to run is terraform init to install the required providers.

When I did that it’s not working though

It says missing provider

Please show the exact output from the init command (formatted correctly so we can read it). That will install the providers needed, and show just the error relevant to your situation.

terraform init

Initializing the backend…

Initializing provider plugins…

  • Finding hashicorp/azurerm versions matching “>= 2.0.0”…
  • Finding hashicorp/random versions matching “>= 3.0.0”…
  • Finding latest version of hashicorp/azure…
  • Installing hashicorp/azurerm v3.10.0…
  • Installed hashicorp/azurerm v3.10.0 (signed by HashiCorp)
  • Installing hashicorp/random v3.3.1…
  • Installed hashicorp/random v3.3.1 (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 Terraform Registry

    │ 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

terraform init

Initializing the backend…

Initializing provider plugins…

  • Finding hashicorp/azurerm versions matching “>= 2.0.0”…
  • Finding hashicorp/random versions matching “>= 3.0.0”…
  • Finding latest version of hashicorp/azure…
  • Installing hashicorp/azurerm v3.10.0…
  • Installed hashicorp/azurerm v3.10.0 (signed by HashiCorp)
  • Installing hashicorp/random v3.3.1…
  • Installed hashicorp/random v3.3.1 (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 Terraform Registry

    │ 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

Terraform itself has already asked you the logical follow up question. What is the answer?

@karthikeyaon.da, the error is showing

Could not retrieve the list of available versions for provider hashicorp/azure

which is because there is no “hashicorp/azure” provider. The most likely guess is that you have a typo in your configuration, where you put “azure” instead of “azurerm” in a resource name.

1 Like