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

"features": required field is not set error for Storage account resource #5867

Closed
sai-ns opened this issue Feb 24, 2020 · 15 comments
Closed

Comments

@sai-ns
Copy link

sai-ns commented Feb 24, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

  • Terraform v0.12.21
  • Azurerm provider v2.0.0

Affected Resource(s)

  • azurerm_storage_account

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp
resource "azurerm_storage_account" "storageacc" {
  name                      = "demostorageacc"
  location                  = "eastus"
  resource_group_name       = "resource-demo-group"
  account_tier              = "Standard"
  account_kind              = "StorageV2"
  account_replication_type  = "LRS"
  access_tier               = "hot"
  
  network_rules {
    default_action = "Allow"
    bypass         = ["AzureServices"]
  }

Description

I was following #5425 to create CORS for blob_properties and had to run terraform init to download new modules/providers/plugins which would support that feature and since then, I am not able to run terraform plan which complains about "features" parameter not set. But that parameter is not part of the resource I am trying to create https://www.terraform.io/docs/providers/azurerm/r/storage_account.html

Debug Output

https://github.com/sai-ns/azure-tf/blob/master/tfdebug

Panic Output

Expected Behavior

Terraform plan should be executed without any issues.

Actual Behavior

Error: "features": required field is not set

Steps to Reproduce

  1. terraform plan

References

@alastairtree

This comment has been minimized.

@DSakura207
Copy link
Contributor

You have to define features block with 2.0 provider.
Everything in it is optional, but you need it.
See https://www.terraform.io/docs/providers/azurerm/index.html#argument-reference.

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

@alastairtree
Copy link
Contributor

@DSakura207 yes thats correct, sorry, should have made clear the 1.X pinning is only require if you dont want to upgrade yet.

@sai-ns
Copy link
Author

sai-ns commented Feb 24, 2020

@DSakura207 thank you. It worked!!
Been waiting for this update for a while to support blob_properties and static_website. But running into issues enabling static_website. Will try to do more digging on it

Error: Error updating Azure Storage Account static_website "storageaccountnamedemo": azure.BearerAuthorizer#WithAuthorization: Failed to refresh the Token for request tohttps://storageaccountnamedemo.blob.core.windows.net?comp=properties&restype=service: StatusCode=400 -- Original Error: adal: Refresh request failed. Status Code = '400'. Response body: {"error":{"code":"invalid_request","message":"No token found for audience https://storage.azure.com/"}}

Edit- Above error disappeared after running apply again

@DSakura207
Copy link
Contributor

@sai-ns That is ... fun. My error is 403, and I have not tried running it twice. I filed a bug report, but maybe it also had something to do with Microsoft.
Anyway, I'll try again with 2.0 again. Hopefully it works.

@lindaburns
Copy link

I tried creating a Simple test Resource group, but kept getting the error specified in 'Actual Behavior'. I had to use version 1.44, and it worked nicely and created the resource group. 2.0 did not work for me.

@squasta
Copy link

squasta commented Feb 25, 2020

I tried creating a Simple test Resource group, but kept getting the error specified in 'Actual Behavior'. I had to use version 1.44, and it worked nicely and created the resource group. 2.0 did not work for me.

Like sai-ns already wrote : add the following code to your terraform code

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

I spend few hours yesterday on a simple Azure Pipeline (that was using a simple tf code to deploy a RG) because of that. Seems like now the provider block is mandantory (it was highly recommended before)

@woeterman94
Copy link

woeterman94 commented Feb 25, 2020

Do we need the
features{} part? What does it do?

nb: #5898

@favandemeer
Copy link

@woeterman94 yes it is required as of version 2.0.0.

You can find more information on this in the docs: https://www.terraform.io/docs/providers/azurerm/index.html#features-2

@mbashtovaya
Copy link

the error message could be a lot more precise so people that have tens of resources created in one script know what terraform block requires "feature"

@bbkane
Copy link

bbkane commented Feb 27, 2020

I ran into this following https://docs.microsoft.com/en-us/learn/modules/provision-infrastructure-azure-pipelines/4-run-terraform-cloud-shell . It'd be nice to update that tutorial with this information

@tombuildsstuff
Copy link
Member

👋 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!

@lindaburns
Copy link

lindaburns commented Mar 4, 2020 via email

@Avani129
Copy link

Avani129 commented Mar 30, 2020

Hi , I have added
provider "azurerm" {
version = "=2.0.0"
features {}
} Still I'm getting features field is not set. any of you getting similar problem ? Please help me

@ghost
Copy link

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 👉 hashibot-feedback@hashicorp.com. Thanks!

@hashicorp hashicorp 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
None yet
Projects
None yet
Development

No branches or pull requests