Getting errors when I run Terraform on VS Code : features required field is not set

i am trying to create a resource group in VS Code:

provider “azurerm” {

version = “=2.0”
}

resource “azurerm_resource_group” “rg” {
name = “Terraform-Test”
location = “West US”
tags = {

environment = "test"

}

}

When i run: Azure Terraform:Plan
I get an error

Error: “features”: required field is not set

I tried everything can someone help me.
Thanks

Try this module
provider “azurerm” {
version = “~> 1.44”
}

That worked, but can you explain why I had to use version 1.44, instead of 2.0.0. I am learning this. thx

Hi,

From 2.0 you need to use a features block.

You also can fix with this
provider “azurerm” {

version = “=2.0”
features {}
}

Thanks that really helped. Your the best. :slight_smile:

hi I updated my code as below still i’m getting error like Error: “features”: required field is not set

provider “azurerm” {
version = “~>2.0.0”
features {}
}
can you please help me

Hi Avani129
Can you try with ‘=’ please?

provider “azurerm” {
version = “=2.0.0”
features {}
}

like that. And let me know what’s the outcome, please.
Cheers
G

I did and didn’t work
I see same error no matter what change I made.When I publish artifacts. I could see those changes were part of the code.

Starting: TerraformCLI

Task : Terraform CLI
Description : Execute terraform cli commands
Version : 0.5.2
Author : Charles Zipp
Help :

/usr/local/bin/terraform version
Terraform v0.12.23

  • provider.azurerm v2.3.0

Your version of Terraform is out of date! The latest version
is 0.12.24. You can update by downloading from https://www.terraform.io/downloads.html

/usr/local/bin/terraform apply -auto-approve -var client_id=() -var client_secret=(client_secret -var ssh_public_key=/home/vsts/work/_temp/azure_rsa.pub
Acquiring state lock. This may take a few moments…

Error: “features”: required field is not set

Releasing state lock. This may take a few moments…

##[error]Terraform command ‘apply’ failed with exit code ‘1’.: “features”: required field is not set
Finishing: TerraformCLI

Hi there,
Shouldn’t you need to re run terraform init in order to download the new version of the provider?
Sorry if I’m wrong

Hi all.

I already have the empty features block, as per the below, but I continue to receive the error when running terraform plan:

provider "azurerm" {
features {}
version = ">=2.0.0"
}

I have also tried pinning the provider version with “=2.0.0”; “=2.1.0”; “=2.2.0”; “=2.3.0”; “=2.4.0”, and each time deleting the .terraform directory, and doing a fresh init, and plan each time. but still get same error every time

Normally I’ve been using “>=2.0.0” ever since the 2.0 AzureRm Provider got released, and I originally added the features block without issue, but now with this error that tells me there is no features block, when in fact I do have a features block - that’s why I’ve been trying all these different version combinations but without luck.

I’ve also tried all of the above with different versions of terraform.exe (0.12.19; 0.12.21; 0.12.24), also deleting the .terraform directory with each new version.

Error: “features”: required field is not set

Any advice would be appreciated. Thank you

Tested all the above on Windows 10 v1809

I have managed to get passed the error. I moved the provider block to main.tf, and I had to create a 2nd provider block for the sub I was accessing. It does not work with just one:

#Azure Provider/s
provider "azurerm" {
  features {}
  version  = ">=2.0.0"
}
 
provider "azurerm" { 
  features {} 
  alias = "cloud_operations"
  subscription_id = var.provider_ids.operations
  skip_provider_registration = "true"
}

Terraform.exe = 0.12.24
AzureRM Provider = 2.4.0

1 Like

Thank you so much @darrens280!!! Worked for me.

2 Likes