You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Terraform创建Storage Account时如何设置cross_tenant_replication_enabled为false

问题

使用Terraform创建Azure存储账户时,尝试设置cross_tenant_replication_enabled = false,配置代码如下:

data "azurerm_resource_group" "data_resource_group" {
  name = var.resource_group_name
}
resource "azurerm_storage_account" "example_storage_account" {
  name                             = var.storage_account_name
  resource_group_name              = data.azurerm_resource_group.data_resource_group.name #(Existing resource group)
  location                         = var.location
  account_tier                     = "Standard"
  account_replication_type         = "LRS"
  allow_nested_items_to_be_public  = false
  cross_tenant_replication_enabled = false
  identity {
    type = "SystemAssigned"
  }
}

执行时出现错误:

Error: Unsupported argument
on ceft_azure/main.tf line 55, in resource "azurerm_storage_account" "example_storage_account":
55: cross_tenant_replication_enabled = false
An argument named "cross_tenant_replication_enabled" is not expected here.

尝试在storage container块中设置该属性也无效,请问如何将该属性值设置为false?

解决方法
  • 升级AzureRM Provider版本:cross_tenant_replication_enabled是AzureRM Provider 3.7.0及以上版本才新增的存储账户顶层参数,低版本Provider不支持该参数。需在配置中指定符合要求的版本:

    terraform {
      required_providers {
        azurerm = {
          source  = "hashicorp/azurerm"
          version = ">= 3.7.0"
        }
      }
    }
    

    执行terraform init -upgrade完成Provider升级。

  • 确认参数配置层级:该参数属于存储账户资源的顶层属性,并非container级配置。只要Provider版本达标,直接在azurerm_storage_account资源块中设置cross_tenant_replication_enabled = false即可生效。

  • 默认值说明:在支持该参数的Provider版本中,cross_tenant_replication_enabled默认值为true,必须显式设置为false才能关闭跨租户复制功能。

内容的提问来源于stack exchange,提问作者user15894

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 20:55:09