/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
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.
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"
}
Hi Darren,
How do you use azuread provider? As per the documentation, I followed this:
provider "azuread" {
# Whilst version is optional, we /strongly recommend/ using it to pin the version of the Provider being used
version = "=0.10.0"
}
But terraform enterprise is expecting a features block, so I added it. But the next run says, features block is not expected here. Quite confused the way this azuread and azurerm providers work with features block. Please assist, thank you!
What happens if you try merge the two azurerm provider sections into one? Having them separated worked for me. Also try move it back to variables.tf to see if that helps…
provider “azurerm” {
features {}
version = “>=2.0.0”
alias = “cloud_operations”
subscription_id = “xxxxxxxx”
skip_provider_registration = “true”
}
Check the double quotes you’re using. I’ve seen this before where copying/pasting quotes causes problems - see screenshot below - 1st set of quotes does not work. 2nd set does work. (perhaps it’s just the way it got pasted here in the forum, but still worth a check)
If you are already on 2.x.x and do have “features{}” in your provider double check if you recently added any new resource blocks and did not include a provider attribute. I recently got that error and had missed the provider in a new resource I created.