Introduction
There is a private provider in the TFE Private Registry and the source is being referenced in the Terraform code as localterraform.com for the hostname.
See the below example:
terraform {
required_version = ">= 2.4.0"
required_providers {
local = {
source = "localterraform.com/org/example"
version = "2.4.0"
}
}
}
Problem
The initialization of the providers with the terraform init command is failing with the following 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
- Private provider available in the TFE Private Registry
Cause
- The localterraform.com generic hostname can only be used for modules sources and not currently supported for providers sources
Solutions:
- Keep in mind that the provider has already been initialized from your previous terraform init run, therefore Terraform will have a reference to localterraform.com in your statefile. The recommendation is to create a new workspace with the correct hostname pointing to the provider.
- Reference the source of the provider with the hostname of your TFE instance as in the example:
terraform {
required_version = ">= 2.4.0"
required_providers {
local = {
source = "<TFE_fully_qualified_domain_name>/org/example"
version = "2.4.0"
}
}
}
Feature Request
- We also have an internal feature request to support the providers to use the generic hostname localterraform.com as the source, however this new functionality has not yet been announced and we do not have any timeline that we can officially communicate at this moment
Outcome
- The error will be fixed and terraform init will be successful