How to use for eg "azurerm.connectivity_subscription" from provider.tf in variables.tf

How to Use “azurerm.connectivity_subscription” in variables.tf

Any help or another exmaple of a way of doingthis would be much appricated.
(Tring to build multiple vm’s for example with static config in main.tf and all vaiables in variables.tf

I get error
│ Error: Invalid provider configuration reference

│ on main.tf line 311, in resource “azurerm_resource_group” “server-rg”:
│ 311: provider = var.server_map[each.key][“provider”]

│ The provider argument requires a provider type name, optionally followed by a period and then a configuration alias.

│ Error: Variables not allowed

│ on variables.tf line 28, in variable “server_map”:
│ 28: provider = azurerm.identity_subscription

│ Variables may not be used here.

Code in main.tf

RESOURCE GROUP

resource “azurerm_resource_group” “server-rg” {
for_each = var.server_map
location = var.server_map[each.key][“location”]
name = var.server_map[each.key][“name”]
provider = var.server_map[each.key][“provider”]
}

NETWORK INTERFACES

resource “azurerm_network_interface” “server-nic” {
for_each = var.server_map
name = var.server_map[each.key][“networkinterfacename”]
location = var.server_map[each.key][“location”]
resource_group_name = var.server_map[each.key][“resourcegroupname”]
provider = var.server_map[each.key][“provider”]
ip_configuration {
name = var.server_map[each.key][“ipname”]
subnet_id = var.server_map[each.key][“ipsubnetid”]
private_ip_address_allocation = var.server_map[each.key][“ipprivate_ip_address_allocation”]
}
}

STORAGE ACCOUNT

resource “azurerm_storage_account” “server-stor” {
for_each = var.server_map
name = var.server_map[each.key][“storageaccountname”] + (random_id.storage_account.hex)
location = var.server_map[each.key][“location”]
resource_group_name = var.server_map[each.key][“resourcegroupname”]
account_tier = var.server_map[each.key][“storageaccounttier”]
account_replication_type = var.server_map[each.key][“storageaccount_replication_type”]
provider = var.server_map[each.key][“provider”]
}

WINDOWS VIRTUAL MACHINE

resource “azurerm_windows_virtual_machine” “server-vm” {
for_each = var.server_map
name = var.server_map[each.key][“vmname”]
admin_username = var.server_map[each.key][“vmadminusername”]
admin_password = random_password.password.result
location = var.server_map[each.key][“location”]
resource_group_name = var.server_map[each.key][“resourcegroupname”]
network_interface_ids = var.server_map[each.key][“vmnetworkinterfaceids”]
size = var.server_map[each.key][“vmsize”]
provider = var.server_map[each.key][“provider”]
os_disk {
name = var.server_map[each.key][“diskname”]
caching = var.server_map[each.key][“diskcaching”]
storage_account_type = var.server_map[each.key][“diskstorageaccounttype”]
}
source_image_reference {
publisher = var.server_map[each.key][“imagepublisher”]
offer = var.server_map[each.key][“imageoffer”]
sku = var.server_map[each.key][“imagesku”]
version = var.server_map[each.key][“imageverson”]
}
boot_diagnostics {
storage_account_uri = var.server_map[each.key][“boostorageaccounturi”]
}
}

code in variables.tf
variable “server_map” {
type = map(map(string))
default = {
AZSDC01 = {
name = “AZSDC01”
location = “australiasoutheast”
resourcegroupname = “AZSDC01-RG”
provider = azurerm.identity_subscription
networkinterfacename = “AZSDC01-NIC”
ipname = “AZSDC01-IPC”
ipsubnetid = azurerm_subnet.azs-identity-sn.id
ipprivateipaddressallocation = “Dynamic”
storageaccountname = “AZSDC01”
storageaccounttier = “Standard”
storageaccountreplicationtype = “LRS”
vmname = “AZSDC01-VM”
vmadminusername = “azureuser”
vmadminpassword = random_password.password.result
vmnetworkinterfaceids = azurerm_network_interface.server-nic.id

code in provider.tf

Identity Subscription

provider “azurerm” {
subscription_id = “xxx.xxx.xxx.xxx.xxx”
features {}
alias = “identity_subscription”
}

worked it out, all good