Same provider with alias errors

so i have found a case i need to pass in different subscription_id when looking up resources cross subscriptions - and it worked in 0.14 but now i am running again in 0.15.1 - i can’t seem to find the solution to this problem

 the root main.tf
    terraform {
      required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = ">= 2.60.0"
      configuration_aliases = [azurerm.westus, azurerm.hub]
    }
      }
      backend "azurerm" {
        resource_group_name  = "rg-********1"
        storage_account_name = "s******3"
        container_name       = "*********"
        key                  = "*********.terraform.tfstate"
      }
    }
    provider "azurerm" {
      features {}
      alias = "westus"
    }
    provider "azurerm" {
      features {}
      alias = "hub"
      subscription_id = "*********************"
    }

    # app registration 
    module "appreg" {
      source    = "./appreg"
      providers = {
         azurerm.westus = azurerm.westus
      }
      team = var.team
      application = var.application
      enviro = var.enviro
    }

the init works without error:

now i am getting 3 warnings i can’t seam to resolve either but the error is what i am most worried about:

│ Warning: Deprecated Attribute

│ The metadata_host provider attribute is deprecated and will be removed in version 2.0


│ Warning: Provider azurerm.westus is undefined

│ on main.tf line 36, in module “appreg”:
│ 36: azurerm.westus = azurerm.westus

│ Module module.appreg does not declare a provider named azurerm.westus.
│ If you wish to specify a provider configuration for the module, add an entry for azurerm.westus in the required_providers block within the module.

│ (and 7 more similar warnings elsewhere)


│ Warning: Provider azurerm.hub is undefined

│ on main.tf line 93, in module “vnet”:
│ 93: azurerm.hub = azurerm.hub

│ Module module.vnet does not declare a provider named azurerm.hub.
│ If you wish to specify a provider configuration for the module, add an entry for azurerm.hub in the required_providers block within the module.


Error: Invalid provider configuration

│ “features”: required field is not set

│ 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.

it doesn’t help when that link “http://registry.terraform.io/hashicorp/azurerm” returns a 404

I am found the solution to the error:

i need a provider block without the alias so now it is:

terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = ">= 2.60.0"
      # configuration_aliases = [azurerm.westus, azurerm.hub]
    }
  }
  backend "azurerm" {
    # access_key           = "************"
    resource_group_name  = "rg-*********1"
    storage_account_name = "st***********3"
    container_name       = "***********"
    key                  = "**********.terraform.tfstate"
  }
}
provider "azurerm" {
  features {}
}
provider "azurerm" {
  features {}
  alias = "westus"
}
provider "azurerm" {
  features {}
  alias = "hub"
  subscription_id = "*********-****-****-****-***********"
}