Introduction
Problem
Terraform plan returns the following error upon invoking a module , the configuration points to a provider uploaded to the private registry
│ Error: Invalid provider configuration
│
│ Provider "registry.terraform.io/hashicorp/azurerm" requires explicit configuration. Add a provider block to the root module and configure the provider's required arguments as described in the provider documentation.
│
╵╷
│ Error: Insufficient features blocks
│
│ on <empty> line 0:
│ (source code not available)
│
│ At least 1 "features" blocks are required.
Cause
When a module lacks a required_providers block, Terraform makes the assumption. It interprets the implicit requirement for the azurerm provider (as suggested by the resource) as a request for the public Hashicorp version.
This behavior can lead to unexpected results in provider inheritance. Terraform may perceive two instances of the azurerm (in the above example) provider as distinct entities, even when they're not, due to the difference in assumed source locations. As a consequence, the intended provider inheritance fails to occur.
This situation underscores the importance of explicitly defining provider requirements in modules to ensure proper inheritance and avoid potential conflicts or misinterpretations by Terraform.
Solutions:
Provider sourcing when not from the the public registry must be present at every module layer.
Hence the required_providers needs to be added to the module configuration
terraform {
required_providers {
azurerm = {
source = "private-provider.com/test/"
version = "3.107.0"
}
}
}