Problem
When using a private provider from the Terraform Enterprise (TFE) Private Registry, terraform init fails if the provider source references the generic localterraform.com hostname.
For example, with the following configuration:
terraform {
required_version = ">= 2.4.0"
required_providers {
local = {
source = "localterraform.com/org/example"
version = "2.4.0"
}
}
}The command fails with this error:
Downloading localterraform.com/org/example/azurerm 1.0.0 for example... - example in terraform/modules/example Initializing provider plugins... - Finding localterraform.com/org/azurerm versions matching ">= 2.4.0" | Error: Failed to query available provider packages Could not retrieve the list of available versions for provider localterraform.com/org/azurerm: provider localterraform.com/org/azurerm was not found in any of the search locations /usr/share/terraform/plugins
Prerequisites
- A private provider is published and available in your TFE Private Registry.
Cause
The generic localterraform.com hostname is only supported for module sources. It is not currently supported for provider sources.
Solutions
Important: After a failed
terraform init, Terraform will have a reference to the incorrectlocalterraform.comhostname in your state file. The recommended approach is to create a new workspace to avoid state corruption before applying the corrected configuration.
Solution 1: Use the TFE Hostname as the Provider Source
Update your Terraform configuration to reference the provider source with the fully qualified domain name (FQDN) of your Terraform Enterprise instance.
terraform {
required_version = ">= 2.4.0"
required_providers {
local = {
source = "<TFE_fully_qualified_domain_name>/org/example"
version = "2.4.0"
}
}
}Replace <TFE_fully_qualified_domain_name> with the actual hostname of your TFE installation.
Outcome
After updating the configuration and initializing in a new workspace, the terraform init command will successfully download the private provider, resolving the error.
Additional Information
- A feature request exists to allow the generic
localterraform.comhostname for provider sources in a future release. At this time, there is no public timeline for this functionality. - For more details on using the registry, refer to the documentation on using the private registry for modules.