我正在尝试使用 azuremrm 资源storage_share实例化 azure storage_share 映射。根据设计,我需要能够使用同一块实例化多个存储共享;每个共享可能有也可能没有“acl”部分。
我正在考虑使用 for_each 与动态块结合使用来解决这个问题,如相关的 SE 问题中所示:
主.tf
resource "azurerm_storage_share" "storage_share" {
for_each = var.storage_share_map
name = each.key
storage_account_name = azurerm_storage_account.sa.name
quota = each.value.quota
dynamic "acl" {
for_each = each.value.acl
content {
id = acl.value.id
access_policy {
permissions = acl.value.access_policy.permissions
start = acl.value.access_policy.start
expiry = acl.value.access_policy.expiry
}
}
}
Run Code Online (Sandbox Code Playgroud)
该变量将定义为:
variable "storage_share_map" {
type = map(object({
quota = number,
acl = object({
id = string,
access_policy = object({
expiry = string,
permissions = string,
start …Run Code Online (Sandbox Code Playgroud)