-1

我已经编写了下面的代码来使用 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 计划时,我遇到了错误。

在此处输入图像描述

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

4

1 回答 1

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
}
于 2020-04-16T16:44:41.613 回答