Problem
When running terraform plan or terraform apply with the Azure Provider (azurerm), the run fails with the following error message:
Error: Insufficient features blocks
Cause
This error typically occurs in one of two scenarios involving the azurerm provider configuration.
Scenario 1: Missing features block
The azurerm provider block is missing the required, empty features {} block.
Example of an incorrect configuration.
provider "azurerm" {
subscription_id = "XXX"
tenant_id = "XXX"
}Scenario 2: Missing default provider with aliases
The configuration uses provider aliases but lacks a default (un-aliased) provider block. If any resource in the configuration does not explicitly reference an alias, Terraform will look for a default provider. If one is not defined, this error will occur.
Example of a failing configuration with only aliased providers.
provider "azurerm" {
alias = "test1"
features {}
subscription_id = "XXX"
tenant_id = "XXX"
}
provider "azurerm" {
alias = "test2"
features {}
subscription_id = "XXX"
tenant_id = "XXX"
}
# This resource does not specify a provider alias, so it fails.
resource "azurerm_resource_group" "example" {
name = "example-cdn-frontdoor"
location = "West Europe"
}Solutions
Depending on the cause, you can apply one of the following solutions.
Solution 1: Add the features block
For configurations missing the features block, add an empty features {} block to the azurerm provider configuration.
provider "azurerm" {
features {}
subscription_id = "XXX"
tenant_id = "XXX"
}Solution 2: Add a default provider or reference an alias
If you are using provider aliases, you have two options.
-
Create a default provider: Add a default
azurermprovider block without analiasargument. This provider will be used by any resource that does not specify aprovidermeta-argument.provider "azurerm" { features {} subscription_id = "XXX" tenant_id = "XXX" } -
Reference an alias in all resources: Ensure every resource in the configuration uses the
providermeta-argument to reference one of the configured provider aliases.resource "azurerm_resource_group" "example" { provider = azurerm.test1 name = "example-cdn-frontdoor" location = "West Europe" }
Outcome
After applying the correct solution, Terraform runs should complete successfully without the Error: Insufficient features blocks message.
Additional Information
- For more details on provider settings, refer to the official Provider Configuration documentation.