Error: Failed to query available provider packages (vRA)

Receiving an error when attempting to initialize Terraform:

 terraform init
Initializing modules...

Initializing the backend...

Initializing provider plugins...
- Finding latest version of hashicorp/vsphere...
- Finding vmware/vra versions matching "0.7.2"...
- Finding latest version of hashicorp/vra...
- Installing hashicorp/vsphere v2.3.1...
- Installed hashicorp/vsphere v2.3.1 (signed by HashiCorp)
- Installing vmware/vra v0.7.2...
- Installed vmware/vra v0.7.2 (signed by a HashiCorp partner, key ID 6B6B0F38607A2264)

Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/cli/plugins/signing.html

 Error: Failed to query available provider packages

 Could not retrieve the list of available versions for provider hashicorp/vra: provider
 registry registry.terraform.io does not have a provider named
 registry.terraform.io/hashicorp/vra

 Did you intend to use vmware/vra? If so, you must specify that source address in each
 module which requires that provider. To see which modules are currently depending on
 hashicorp/vra, run the following command:
     terraform providers

I am unsure why hashicorp/vra is being called at this point as I assume backwards-compatibility has been sunset at this point. The code is very simple:

terraform {
  required_providers {
    vra = {
      source = "vmware/vra"
      version = "0.7.2"
    }
  }
}

provider "vra" {
  url           = var.vra_url
  refresh_token = var.vra_refresh_token
  insecure      = var.vra_insecure
}

module "vsphere_cloud_account_1" {
  source                                                    = "./modules/cloud-account-vsphere"
  count                                                      = var.create_cloud ? 1: 0
  vsphere_cloud_account_description  = ""
  vsphere_datacenter_names               = var.vsphere_datacenter_names
  vsphere_datacenter_ids                      = var.vsphere_datacenter_ids
  vsphere_cloud_account_name           = ""
  capability_tags                                       = var.capability_tags
  vsphere_hostname                               = ""
  data_collector_name                            = var.data_collector_name
  vsphere_username                               = var.username
  vsphere_password                                = var.password
  tags = [
    {
      tag   = "xxx",
      value = "xxx"
    },
    {
      tag   = "xxx",
      value = "xxx"
    },
    {
      tag   = "xxx",
      value = "xxx"
    }
  ]
}

Output from terraform providers command:


terraform providers

Providers required by configuration:

── provider[registry.terraform.io/vmware/vra] 0.7.2
└── module.vsphere_cloud_account_1
    ── provider[registry.terraform.io/hashicorp/vsphere]
    └── provider[registry.terraform.io/hashicorp/vra]


Assuming this is a backwards compatibility issue, where do I go from here? If not, is there any reason Terraform is looking for the provider at https://registry.terraform.io/hashicorp/vra/ ?

In Terraform, the mapping from provider local name (vra) to provider address (vmware/vra) is specific to each module - that is, each directory level.

That means you are missing

terraform {
  required_providers {
    vra = {
      source = "vmware/vra"
    }
  }
}

in the ./modules/cloud-account-vsphere directory.

Oh if only that were true. If it was, you might get a far more useful error message. But no, within your ./modules/cloud-account-vsphere directory, backwards compatibility rules take effect and map the otherwise-unspecified vra to hashicorp/vra.

My goodness I looked at that error for so long I didn’t think about the obvious. Sorry to have troubled you and thank you for the help :slight_smile: