azure/vnet/azurerm terraform 模块中子网委托块的正确语法是什么?

What is the correct syntax for the subnet delegation block in azure/vnet/azurerm terraform module?

我想使用 azure/vnet/azurerm Terraform 模块 (https://registry.terraform.io/modules/Azure/vnet/azurerm/latest) 将 Vnet 部署到 Azure。

module "vnet" {
  source              = "Azure/vnet/azurerm"
  resource_group_name = "my-resources"
  address_space       = ["10.0.0.0/16"]
  subnet_prefixes     = ["10.0.1.0/24", "10.0.2.0/24"]
  subnet_names        = ["subnet1", "subnet2"]

  subnet_delegation = {
    subnet2 = {
      name    = "Microsoft.DBforPostgreSQL/flexibleServers"
      actions = "Microsoft.Network/virtualNetworks/subnets/join/action"
    }
  }
}

我写了这段代码,当我想“terraform plan”时,我得到了这个错误:

Error: Invalid function argument
│ 
│   on .terraform/modules/vnet/main.tf line 30, in resource "azurerm_subnet" "subnet":
│   30:         name    = lookup(delegation.value, "service_name")
│     ├────────────────
│     │ delegation.value is "Microsoft.Network/virtualNetworks/subnets/join/action"
│ 
│ Invalid value for "inputMap" parameter: lookup() requires a map as the first argument.


Error: Invalid function argument
│ 
│   on .terraform/modules/vnet/main.tf line 30, in resource "azurerm_subnet" "subnet":
│   30:         name    = lookup(delegation.value, "service_name")
│     ├────────────────
│     │ delegation.value is "Microsoft.DBforPostgreSQL/flexibleServers"
│ 
│ Invalid value for "inputMap" parameter: lookup() requires a map as the first argument.

有人用过这个模块并用过子网委托吗? 我需要“subnet_delegation”的语法以避免此错误。

谢谢!

这是该块的示例,摘自 here

subnet_delegation = {
    subnet2 = {
      "Microsoft.Sql.managedInstances" = {
        service_name = "Microsoft.Sql/managedInstances"
        service_actions = [
          "Microsoft.Network/virtualNetworks/subnets/join/action",
          "Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action",
          "Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action",
        ]
      }
    }
  }