1

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

1
  • Add Blob properties block like this: blob_properties { cors_rule { allowed_methods = var.allowed_methods allowed_origins = var.allowed_origins allowed_headers = var.allowed_headers exposed_headers = var.exposed_headers max_age_in_seconds = var.max_age_in_seconds } } Commented Jul 30, 2021 at 13:53

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.