取消绑定以使用terraform将Azure网络安全组与具有计数值的NIC连接

取消绑定以使用terraform将Azure网络安全组与具有计数值的NIC连接,azure,terraform,azure-rm,virtual-network-interface,Azure,Terraform,Azure Rm,Virtual Network Interface,我已经编写了下面的代码,使用terraform将安全组与网络接口连接起来 resource "azurerm_network_interface_security_group_association" "attach_Nic_Nsg" { count = 2 network_interface_id = "${azurerm_network_interface.network_interface[count.index].id

我已经编写了下面的代码,使用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
}
当我执行地形计划时,我得到了以下错误


如何为多个Nic连接网络安全组?

下面的代码片段解决了我的问题

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
}