Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: "features": required field is not set #5893

Closed
ghost opened this issue Feb 25, 2020 · 8 comments
Closed

Error: "features": required field is not set #5893

ghost opened this issue Feb 25, 2020 · 8 comments
Labels

Comments

@ghost
Copy link

ghost commented Feb 25, 2020

This issue was originally opened by @axelthimm as hashicorp/terraform#24200. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.12.21

  • provider.azurerm v2.0.0
Terraform v0.12.21
+ provider.azurerm v2.0.0
...

Terraform Configuration Files

unknown due to terse error output
...

Debug Output

2020/02/24 19:37:30 [TRACE] BuiltinEvalContext: Initialized "azurerm" provider for provider.azurerm
2020/02/24 19:37:30 [TRACE] <root>: eval: terraform.EvalNoop
2020/02/24 19:37:30 [TRACE] <root>: eval: *terraform.EvalOpFilter
2020/02/24 19:37:30 [TRACE] <root>: eval: *terraform.EvalSequence
2020/02/24 19:37:30 [TRACE] <root>: eval: *terraform.EvalGetProvider
2020/02/24 19:37:30 [TRACE] <root>: eval: *terraform.EvalValidateProvider
2020/02/24 19:37:30 [TRACE] buildProviderConfig for provider.azurerm: using explicit config only
2020/02/24 19:37:30 [TRACE] GRPCProvider: GetSchema
2020/02/24 19:37:30 [TRACE] GRPCProvider: PrepareProviderConfig
2020/02/24 19:37:30 [WARN] <root>: eval: *terraform.EvalValidateProvider, non-fatal err: "features": required field is not set
2020/02/24 19:37:30 [ERROR] <root>: eval: *terraform.EvalSequence, err: "features": required field is not set
2020/02/24 19:37:30 [ERROR] <root>: eval: *terraform.EvalOpFilter, err: "features": required field is not set
2020/02/24 19:37:30 [ERROR] <root>: eval: *terraform.EvalSequence, err: "features": required field is not set
2020/02/24 19:37:30 [TRACE] [walkValidate] Exiting eval tree: provider.azurerm
2020/02/24 19:37:30 [TRACE] vertex "provider.azurerm": visit complete

Expected Behavior

A useful error indicating file and line the error is to be searched at.

Actual Behavior

Steps to Reproduce

$ terraform init -upgrade && terraform plan -target=module.base
Upgrading modules...

  • base in modules/azure/base
  • [...]
  • gitlab_runner.subnet in modules/azure/subnet

Initializing the backend...

Initializing provider plugins...

  • Checking for available provider plugins...
  • Downloading plugin for provider "azurerm" (hashicorp/azurerm) 2.0.0...

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.

  • provider.azurerm: version = "~> 2.0"

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

Error: "features": required field is not set

Additional Context

The -target above is not part of the issue, it fails w/o -target and with any other targeted resource.
Also "features" is not referenced anywhere (but the Azure provider) - so perhaps it's a provider bug?

$ grep -r features .
Binary file ./.terraform/plugins/linux_amd64/terraform-provider-azurerm_v2.0.0_x5 matches

@arkiaconsulting
Copy link

A workaround is to specify a features block (even empty) in the azurerm provider block

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

@jbobbylopez
Copy link

@arkiaconsulting I've tried using azrurerm v2.0 with the features block as you suggested, however when I do that I still get a compatibility error, as follows:

 $  terraform init
Initializing modules...
- azure_app in ../../../application
- azure_sp in ../..

Initializing the backend...

Initializing provider plugins...
- Checking for available provider plugins...

No available provider "azure" plugins are compatible with this Terraform version.

From time to time, new Terraform major releases can change the requirements for
plugins such that older plugins become incompatible.

Terraform checked all of the plugin versions matching the given constraint:
    (any version)

Unfortunately, none of the suitable versions are compatible with this version
of Terraform. If you have recently upgraded Terraform, it may be necessary to
move to a newer major release of this provider. Alternatively, if you are
attempting to upgrade the provider to a new major version you may need to
also upgrade Terraform to support the new version.

Consult the documentation for this provider for more information on
compatibility between provider versions and Terraform versions.

- Downloading plugin for provider "azurerm" (hashicorp/azurerm) 2.0.0...
- Downloading plugin for provider "azuread" (hashicorp/azuread) 0.7.0...

Error: no available version is compatible with this version of Terraform

# And the terraform version
 $  terraform version
Terraform v0.12.21

@arkiaconsulting
Copy link

arkiaconsulting commented Mar 3, 2020

@jbobbylopez I don’t think that this is related to the current issue. I guess that the azuread team didn’t mark their provider to be compatible with the 0.12.21 terraform version.

@jbobbylopez
Copy link

Thanks @arkiaconsulting, I filed the following issue for 'azuread' for this:
hashicorp/terraform-provider-azuread#219

@tombuildsstuff
Copy link
Contributor

👋 hi folks

As mentioned in the changelog, version 2.0 of the Azure Provider now requires that a provider block be defined and a features block be defined within it. The features block is new in version 2.0 of the Azure Provider and allows controlling of the behaviour of certain resources (including whether data disks/key vaults should be purged).

Since this controls the behaviour of the Provider this block is now required as we believe it's important that folks are aware which Provider block is being used, since this was ambiguous as it was optional in 1.x (and thus we often saw confusion where users were using one provider block when they thought they were using another with modules).

As mentioned above this should be a case of updating your Terraform Configurations to include a Provider block as shown below:

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

#5880 is tracking adding some additional documentation for this however since this should be fixed by updating the Terraform Configuration to include the provider block I'm going to close this issue for the moment, since this is by design in version 2.0 (and upwards) of the Azure Provider.

Thanks!

@ElvenSpellmaker
Copy link
Contributor

ElvenSpellmaker commented Mar 10, 2020

@tombuildsstuff That error message is really awful, is there no way to make terraform output a more sane error message? I had absolutely no idea where it came from, or how to solve it either. I assume someone had added a variable to the vars.tf somehow.

(I forgot to commit a providers file and it auto-upgraded this part of the pipeline to v2 provider and so accidentally came across this error.)

@Darkbat91
Copy link

This error also happens if you have aliased your provisioners and leave a resource without a provider. I assume because it automatically tries to import a blank azurerm provider without the features block.

provider azurerm {
  alias           = "production"
  subscription_id = "xxxxx-xxxxxx-xxxxxx-xxxxxx"
  # whilst the `version` attribute is optional, we recommend pinning to a given version of the Provider
  version = "=2.0.0"
  features {}
}

resource azurerm_storage_share storage {
  provider             = azurerm.production# this this line missing you get the error
  name                 = "storage"
  storage_account_name = azurerm_storage_account.configstor.name
  quota                = 50
}

@ghost
Copy link
Author

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants