Insufficient features blocks issue on modules with multiple providers

Hi

I have multiple subscriptions and require to place resources in different subscriptions during an apply.

my global.tf includes:

terraform {
  required_version = "~>0.15"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "=2.66.0"
    }
    azuread = {
      source  = "hashicorp/azuread"
      version = "~>1.5.0"
    }
    cloudinit = {
      source  = "hashicorp/cloudinit"
      version = "=2.2.0"
    }
  }
  backend "azurerm" {
    storage_account_name = "xxxx"
    container_name       = "tfstate"
    key                  = "nextgen.terraform.state"
  }
}
# This is our default subscription with core infra
provider "azurerm" {
  features {}
  alias           = "default"
  subscription_id = "xxx"
  tenant_id       = "yyy"
}
# This is the subscription we want to deploy to
provider "azurerm" {
  features {}
  alias           = "internal"
  subscription_id = module.client2sub.subscription_id
  tenant_id       = "yyy"
}

I have several modules with each having a main.tf including:

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "=2.66.0"
      configuration_aliases = [ azurerm.default, azurerm.internal ]
    }
  }
}

then when i call a module I use:

module "peer_networks" {
  # depends_on = [module.networking]
  for_each = toset(var.environments)
  source   = "../modules/vnet_peering"
  providers = {
    azurerm.default  = azurerm.default
    azurerm.internal = azurerm.internal
  }

  connect_to_workbench = local.connect_to_workbench
  rg_name              = module.resource_group.rg[each.key].name
  location             = var.location
  vnet_source          = module.networking.vnet_object[each.key]
  vnet_regional_hub    = data.azurerm_virtual_network.hub_vnet_regional_hub
  vnet_us_hub          = data.azurerm_virtual_network.hub_vnet_us
  vnet_eu_hub          = data.azurerm_virtual_network.hub_vnet_eu
  subscription         = module.client2sub.subscription_id
}

When I apply, I am getting:


│ Error: Insufficient features blocks
│ 
│   on  line 0:
│   (source code not available)
│ 
│ At least 1 "features" blocks are required.
╵

But I have the features block defined in my global.

TF 15.5 / 1.0.1 tried out.

Any ideas?

1 Like

Got the same issue. terraform 0.15.3/1.0.3

After a several hours of total headache it was fixed by adding an empty azurerm provider block into configuration:

#region Azure aliased providers
provider "azurerm" {
  alias           = "stage1"
  subscription_id = "yyy"
  tenant_id       = "xxx"

  features {}
}

provider "azurerm" {
  alias           = "prod1"
  subscription_id = "yyy"
  tenant_id       = "xxx"

  features {}
}

#endregion

provider "azurerm" {
  features {}
}

terraform {
  backend "local" {}
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~>2.0"
    }
  } 
}

provider "azurerm" {
  features {}
}

I am still getting the below error

│ Error: Insufficient features blocks

│ on line 0:
│ (source code not available)

│ At least 1 “features” blocks are required.

Any thoughts ? I used dummy credentials instead of originals, is that a problem ? or is it related to code ?

For anyone else who stumbles across this, since I assume OP has resolved their issue:

If all of your providers are aliased, you have no default. This means EVERY resource from that provider will need the provider property set. If you have a resource from that provider that does not have a provider specified, Terraform creates and empty provider config, hence the “insufficient features blocks”.