Problem with resource "azurerm_network_interface"

I would like to ask how I can add the name of a Network Security Group when creating a new network interface resource azurerm_network_interface. This NSG already exists in Azure, and I am using the HashiCorp azurerm provider version 4.8.0.

There you go


data "azurerm_network_security_group" "example" {
  name                = "example"
  resource_group_name = resource_group_name
}

resource "azurerm_network_interface_security_group_association" "example" {
  network_interface_id      = azurerm_network_interface.example.id
  network_security_group_id = data.azurerm_network_security_group.example.id
}

1 Like