Error: Failed to query available provider packages1

main.tf

terraform {

  required_providers {

    azurerm =  "~> 2.33"

    random = "~> 2.2"

    databricks = "~> 0.5"

}

}

provider "azurerm" {

features {}

client_id = "8db67d23-e28a-4499-9396-92ae78567ec4"

client_secret = "NpD7Q~G8bmX2iOO1-Z-9OI5R5CK32O.m2VruE"

tenant_id = "afd106ce-9134-48c3-b3be-63d51306d4e5"

subscription_id = "302af5ae-a1ad-4b48-bac2-c0181e86705d"

}

provider "databricks" {

  features {}

modules.tf

locals {

    env = "dev"

    sub = "302af5ae-a1ad-4b48-bac2-c0181e86705d"

  rgname = "${local.env}-freetrail-rg"

  rglocation = "eastus"

  vnetname = "freetrailvnet"

  subnetname1 = "subnet1"

}

module "rg" {

    source = "../Modules/ResourceGroup"

  rgname = local.rgname

  rglocation = local.rglocation

}

module "vnet" {

  source = "../Modules/VNet"

  rgname = local.rgname

  rglocation = local.rglocation

  vnetname = "freetrailvnet"

  address_space = ["10.0.0.0/8"]

  subnetname1 = "subnet1"

  subnetprefix1 = ["10.0.1.0/24"]

  subnetname2 = "subnet2"

  subnetprefix2 = ["10.0.2.0/24"]

  nsgname = "freetrailnsg"

  depends_on = [

    module.rg

  ]

}

module "adf" {

  source = "../Modules/ADF"

  rgname = local.rgname

  rglocation = local.rglocation

  adfname = "dev-freetrail-adf"

  irname = "IntegrationRuntime01"

#   prefix = "${local.env}-adf"

#   vnetname = "freetrailvnet" #module.vnet.virtual_network_name

#   subnetname1 = "subnet1" #module.vnet.subnetname1

#   subnet_id = "/subscriptions/${local.sub}/resourceGroups/${local.rgname}/providers/Microsoft.Network/virtualNetworks/${local.vnetname}/subnets/${local.subnetname1}"

    depends_on = [module.rg,module.keyvault]

}

module "storage" {

        source = "../Modules/Storage"

   strname = "adfstorage2345"

     rgname = local.rgname

   rglocation = local.rglocation

     depends_on = [module.rg,module.adf]

}

module "keyvault" {

        source = "../Modules/KeyVault"

   keyvaultname = "devkvasdfasdf"

     rgname = local.rgname

   rglocation = local.rglocation

     depends_on = [module.rg]

}

module "sqlserver" {

  source = "../Modules/Sql"

  sqlservername = "devsqlsrvasdfasdf"

  sqldbname = "devdbasdfasdf"

   rgname = local.rgname

   rglocation = local.rglocation

   depends_on = [

     module.rg,module.keyvault

   ]

}

module "databricks" {

  source = "../Modules/DataBricks"

  rgname = local.rgname

  rglocation = local.rglocation

  dtbrickname = "${local.env}-databricks-testsdfasf"

     depends_on = [module.rg]

}

module "cluster" {

  source = "../Modules/Cluster"

  depends_on = [azurerm_databricks_workspace.myworkspace]

}

getting error:

│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/databricks: provider registry registry.terraform.io does not have a provider named
│ registry.terraform.io/hashicorp/databricks
│
│ All modules should specify their required_providers so that external consumers will get the correct providers when using a module. To see which modules are currently depending on
│ hashicorp/databricks, run the following command:
│     terraform providers
╵

Hi @sreekanthreddy.devop,

This error message is correct that there isn’t a provider called hashicorp/databricks. From looking at the Terraform Registry it seems like the provider you wanted here might be databrickslabs/databricks, which is a provider maintained by Databricks Labs.

You used a legacy-style required_providers block in your example, using syntax from before Terraform supported third-party providers, and so Terraform is assuming that you want to install hashicorp/-namespaced providers for all of them as a way to stay compatible with Terraform modules written for Terraform v0.12.

The modern way to write this would be to specify a source location for each provider, so that Terraform can see which registry namespace each provider belongs to:

terraform {
  required_providers {
    azurerm =  {
      source  = "hashicorp/azurerm"
      version = "~> 2.33"
    }
    databricks = {
      source  = "databrickslabs/databricks"
      version = "~> 0.5"
    }
    random = {
      source  = "hashicorp/random"
      version = "~> 2.2"
    }
  }
}

You’ll need to specify requirements like this for each module, so that the modules will all agree on which provider to use for databricks. The databricks clause in the above example means "in this module only, the short name databricks represents the provider databrickslabs/databricks, and so you need to repeat that statement for each module that will use this provider.

Please check to make sure that databrickslabs/databricks is indeed the provider you intended to use. There can potentially be many providers with the same name in different namespaces on the Terraform Registry, and so if you intended to use a different provider named “databricks” you’ll nede to find that in the registry yourself to find out what its namespace is.