Search code examples
azure-storageterraformterraform-provider-azure

Error creating Azure Storage account using Terraform


I'm creating a storage account using Terraform v0.12.9 and provider.azurerm v1.34.0

Here is my code

resource "azurerm_storage_account" "platform" {

  name                     = "${var.name}"
  resource_group_name      = "${var.resource_group_name}"
  location                 = "${var.location}"
  account_kind             = "${var.account_kind}"
  account_tier             = "${var.account_tier}"
  account_replication_type = "${var.account_replication_type}"
  access_tier              = "${var.access_tier}"
  enable_blob_encryption   = "${var.enable_blob_encryption}"
  enable_file_encryption   = "${var.enable_file_encryption}"
  enable_https_traffic_only= "${var.enable_https_traffic_only}"

  tags = {
    environment = "test"
  }

  cors_rule = {
    allowed_headers   = ["*"]
    allowed_methods   = ["Get"]
    allowed_origins   = ["*"]
    exposed_headers   = ["*"]
    max_age_in_seconds= "1"
  }
}

I'm getting the following error for cors_rule argument.

Error: Unsupported argument

  on main.tf line 17, in resource "azurerm_storage_account" "platform":
  17:   cors_rule = {

An argument named "cors_rule" is not expected here.

Even though it is specified in the documentation available here https://www.terraform.io/docs/providers/azurerm/r/storage_account.html#allowed_headers


Solution

  • The documentation states that the cors_rule block should be nested in the queue_properties block, but I agree, the documentation does not specify it clearly.

    You can always check the provider on github to see the actual structure. I find this works better then looking at the documentation as the documentation can be confusing sometimes. Of course I then recommend creating a PR that makes the documentation clearer.