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

