Error: Insufficient features blocks! Finally

I know there are many (actually 5) topics with the same problem statement but there is no clear understanding and solution.

I’d like to make it resolved here.

The error:

Error: Insufficient features blocks

  on <empty> line 0:
  (source code not available)

At least 1 "features" blocks are required.

Version:

Terraform v1.1.5
on linux_amd64
+ provider registry.terraform.io/hashicorp/azurerm v2.95.0
+ provider registry.terraform.io/hashicorp/external v2.2.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/hashicorp/vault v3.3.1

The codebase has a dedicated file with the name gen_provider.tf

# Generated by Terragrunt. Sig: nIlQXj57tbuaRZEa
provider "azurerm" {
  subscription_id = XXX
  client_id       = XXX
  client_secret   = XXX
  tenant_id       = XXX
  features {}
}

terraform {

terraform validation passed successfully. (it checks azurerm feature block gap)

Trace log (near error):

2022-03-07T13:11:23.394Z [DEBUG] provider: using plugin: version=5
2022-03-07T13:11:23.395Z [DEBUG] provider.terraform-provider-azurerm_v2.95.0_x5: plugin address: address=/tmp/plugin985937110 network=unix timestamp=2022-03-07T13:11:23.394Z
2022-03-07T13:11:23.456Z [TRACE] BuiltinEvalContext: Initialized "provider[\"registry.terraform.io/hashicorp/azurerm\"]" provider for provider["registry.terraform.io/hashicorp/azurerm"]
2022-03-07T13:11:23.456Z [TRACE] NodeApplyableProvider: configuring provider["registry.terraform.io/hashicorp/azurerm"]
2022-03-07T13:11:23.456Z [TRACE] buildProviderConfig for provider["registry.terraform.io/hashicorp/azurerm"]: no configuration at all
2022-03-07T13:11:23.456Z [TRACE] GRPCProvider: GetProviderSchema
2022-03-07T13:11:23.456Z [DEBUG] created provider logger: level=trace
2022-03-07T13:11:23.457Z [INFO]  provider: configuring client automatic mTLS
2022-03-07T13:11:23.458Z [TRACE] provider.stdio: waiting for stdio data
2022-03-07T13:11:23.468Z [TRACE] provider.terraform-provider-azurerm_v2.95.0_x5: Received request: @caller=/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server/server.go:329 tf_provider_addr=provider tf_rpc=GetSchema @module=sdk.proto tf_proto_version=5 tf_req_id=0ba33a52-a68f-c6cb-0fe2-df029f7e4a60 timestamp=2022-03-07T13:11:23.463Z
2022-03-07T13:11:23.468Z [TRACE] provider.terraform-provider-azurerm_v2.95.0_x5: Calling downstream: @module=sdk.proto tf_proto_version=5 tf_req_id=0ba33a52-a68f-c6cb-0fe2-df029f7e4a60 @caller=/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server/server.go:336 tf_provider_addr=provider tf_rpc=GetSchema timestamp=2022-03-07T13:11:23.464Z
2022-03-07T13:11:23.497Z [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/vault/3.3.1/linux_amd64/terraform-provider-vault_v3.3.1_x4 args=[.terraform/providers/registry.terraform.io/hashicorp/vault/3.3.1/linux_amd64/terraform-provider-vault_v3.3.1_x4]
2022-03-07T13:11:23.502Z [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/vault/3.3.1/linux_amd64/terraform-provider-vault_v3.3.1_x4 pid=40666
2022-03-07T13:11:23.502Z [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/vault/3.3.1/linux_amd64/terraform-provider-vault_v3.3.1_x4
2022-03-07T13:11:23.570Z [TRACE] provider.terraform-provider-azurerm_v2.95.0_x5: Called downstream: tf_provider_addr=provider tf_rpc=GetSchema @module=sdk.proto tf_proto_version=5 tf_req_id=0ba33a52-a68f-c6cb-0fe2-df029f7e4a60 @caller=/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server/server.go:342 timestamp=2022-03-07T13:11:23.568Z
2022-03-07T13:11:23.575Z [INFO]  provider.terraform-provider-vault_v3.3.1_x4: configuring server automatic mTLS: timestamp=2022-03-07T13:11:23.573Z
2022-03-07T13:11:23.648Z [DEBUG] provider: using plugin: version=5
2022-03-07T13:11:23.649Z [DEBUG] provider.terraform-provider-vault_v3.3.1_x4: plugin address: address=/tmp/plugin3587123391 network=unix timestamp=2022-03-07T13:11:23.647Z
2022-03-07T13:11:23.693Z [TRACE] provider.terraform-provider-azurerm_v2.95.0_x5: Served request: tf_provider_addr=provider @caller=/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server/server.go:348 @module=sdk.proto tf_req_id=0ba33a52-a68f-c6cb-0fe2-df029f7e4a60 tf_rpc=GetSchema tf_proto_version=5 timestamp=2022-03-07T13:11:23.673Z
2022-03-07T13:11:23.730Z [TRACE] BuiltinEvalContext: Initialized "provider[\"registry.terraform.io/hashicorp/vault\"]" provider for provider["registry.terraform.io/hashicorp/vault"]
2022-03-07T13:11:23.730Z [DEBUG] created provider logger: level=trace
2022-03-07T13:11:23.730Z [INFO]  provider: configuring client automatic mTLS
2022-03-07T13:11:23.746Z [TRACE] provider.stdio: waiting for stdio data
2022-03-07T13:11:23.788Z [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/external/2.2.0/linux_amd64/terraform-provider-external_v2.2.0_x5 args=[.terraform/providers/registry.terraform.io/hashicorp/external/2.2.0/linux_amd64/terraform-provider-external_v2.2.0_x5]
2022-03-07T13:11:23.794Z [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/external/2.2.0/linux_amd64/terraform-provider-external_v2.2.0_x5 pid=40674
2022-03-07T13:11:23.794Z [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/external/2.2.0/linux_amd64/terraform-provider-external_v2.2.0_x5
2022-03-07T13:11:23.823Z [INFO]  provider.terraform-provider-external_v2.2.0_x5: configuring server automatic mTLS: timestamp=2022-03-07T13:11:23.818Z
2022-03-07T13:11:24.135Z [DEBUG] provider: using plugin: version=5
2022-03-07T13:11:24.136Z [DEBUG] provider.terraform-provider-external_v2.2.0_x5: plugin address: address=/tmp/plugin064506927 network=unix timestamp=2022-03-07T13:11:24.124Z
2022-03-07T13:11:24.207Z [ERROR] vertex "provider[\"registry.terraform.io/hashicorp/azurerm\"]" error: Insufficient features blocks
2022-03-07T13:11:24.207Z [TRACE] vertex "provider[\"registry.terraform.io/hashicorp/azurerm\"]": visit complete, with errors
2022-03-07T13:11:24.207Z [TRACE] dag/walk: upstream of "module.tfstates.data.azurerm_resource_group.tfstate (expand)" errored, so skipping
2022-03-07T13:11:24.215Z [TRACE] dag/walk: upstream of "module.tfstates.azurerm_storage_account.tfstate (expand)" errored, so skipping
2022-03-07T13:11:24.215Z [TRACE] dag/walk: upstream of "module.tfstates.data.azurerm_storage_account.level3 (expand)" errored, so skipping

Trace log msg(s) with other [ERROR] levels:

2022-03-07T13:11:20.818Z [ERROR] AttachSchemaTransformer: No provider config schema available for provider["terraform.io/builtin/terraform"]
2022-03-07T13:11:22.978Z [ERROR] AttachSchemaTransformer: No provider config schema available for provider["terraform.io/builtin/terraform"]
2022-03-07T13:11:24.207Z [ERROR] vertex "provider[\"registry.terraform.io/hashicorp/azurerm\"]" error: Insufficient features blocks
2022-03-07T13:12:45.118Z [ERROR] AttachSchemaTransformer: No provider config schema available for provider["terraform.io/builtin/terraform"]
2022-03-07T13:12:48.158Z [ERROR] AttachSchemaTransformer: No provider config schema available for provider["terraform.io/builtin/terraform"]
2022-03-07T13:12:50.772Z [ERROR] vertex "provider[\"registry.terraform.io/hashicorp/azurerm\"]" error: Insufficient features blocks

I’m happy to provide any additional information (code, logs, etc).

The situation is really weird.

here is the minimal tf to reproduce the issue

terraform {
  backend "azurerm" {
    storage_account_name = "XXX"
    container_name       = "XXX"
    key                  = "XXX"
    access_key           = "XXX"
  }
}

provider "azurerm" {
  features {}
}

/* 
data "azurerm_storage_account" "level0" {
  name                = "XXX"
  resource_group_name = "XXX"
} */

  • plan worked w/o data “azurerm_storage_account” “level0”
  • with data “azurerm_storage_account” “level0” it false with no features {} block issue.
Error: Insufficient features blocks

  on <empty> line 0:
  (source code not available)

At least 1 "features" blocks are required

I have the same issue (error code) with bit different conditions:

2 providers - “microsoft/azuredevops” and “hashicorp/azurerm”
normally (previously worked with azuredevops) the first provider doesn’t accept any features in provider block:

Error: Unsupported block type
│
│   on modules\ADO\provider.tf line 13, in provider "devops":
│   13:   features {}
│
│ Blocks of type "features" are not expected here.

when I’m removing features block - then I get:

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

WTF???

my providers looks like:

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = ">= 3.2.0"
    }
  }
}

provider "azurerm" {
  features {
    log_analytics_workspace {
      permanently_delete_on_destroy = true
    }
    resource_group {
      prevent_deletion_if_contains_resources = true
    }
    key_vault {
      purge_soft_delete_on_destroy               = true
      purge_soft_deleted_secrets_on_destroy      = true
      purge_soft_deleted_certificates_on_destroy = true
    }
  }
  skip_provider_registration = true
}

and

terraform {
  required_providers {
    devops = {
      source  = "microsoft/azuredevops"
      version = ">= 0.2.1"
    }
  }
}

provider "devops" {
  org_service_url       = var.ado_organization_url
  personal_access_token = var.ado_pat
}

and versions are:

Terraform v1.1.9
on windows_386
+ provider registry.terraform.io/hashicorp/azurerm v3.3.0
+ provider registry.terraform.io/hashicorp/random v3.1.3
+ provider registry.terraform.io/microsoft/azuredevops v0.2.1

(searching rest of a code for words provider/providers/etc… is not giving me any other matches - read that as there is no other places with provider definitions.)

even disabling (commenting) whole 2nd provider (azuredevops) and removing module/ADO from code tree - I’m getting the same error type.
Funny part:
before I started modifying code for azuredevops and it’s functions - the code was running correctly, now removing everything back is not - magic…