使用Terraform创建Azure存储帐户时出错

时间:2019-09-27 12:30:07

标签: azure-storage terraform terraform-provider-azure

我正在使用Terraform v0.12.9和provider.azurerm v1.34.0创建存储帐户

这是我的代码

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"
  }
}

cors_rule参数出现以下错误。

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.

即使在此处提供的文档中已指定 https://www.terraform.io/docs/providers/azurerm/r/storage_account.html#allowed_headers

1 个答案:

答案 0 :(得分:2)

文档指出cors_rule块应该嵌套在queue_properties块中,但是我同意,文档没有明确指定。

您随时可以在github上查看提供者,以查看实际结构。我发现这比查看文档更好,因为文档有时会令人困惑。当然,然后我建议创建一个PR,以使文档更加清晰。