【问题标题】:unble to attach Azure network security group with NIC with count value using terraform无法使用 terraform 将带有计数值的 NIC 附加 Azure 网络安全组
【发布时间】:2020-04-16 16:18:58
【问题描述】:

我已经编写了下面的代码来使用 terraform 将安全组与网络接口连接起来。

resource "azurerm_network_interface_security_group_association" "attach_Nic_Nsg" {
     count                     = 2
     network_interface_id      = "${azurerm_network_interface.network_interface[count.index].id}"
     network_security_group_id = module.security_group.security_group_id
}

当我执行 terraform 计划时,我遇到了错误。

如何为多个网卡附加网络安全组?

【问题讨论】:

    标签: azure terraform azure-rm virtual-network-interface


    【解决方案1】:

    下面的片段解决了我的问题。

    resource "azurerm_network_interface_security_group_association" "attach_Nic_Nsg" {
        count                     = 2
        network_interface_id      = element(azurerm_network_interface.network_interface.*.id, count.index)
        network_security_group_id = module.security_group.security_group_id
    }
    

    【讨论】:

      猜你喜欢
      • 2018-07-11
      • 2020-04-21
      • 2015-03-08
      • 2022-07-26
      • 2023-03-30
      • 1970-01-01
      • 2022-01-15
      • 1970-01-01
      • 2022-01-15
      相关资源
      最近更新 更多