Learn Terraform - Azure - Resource Dependencies sample code issue

The sample at the bottom of the Learn Terraform - Azure - Resource Dependencies page seems to be out of sync with the current version of Terraform (0.12.24).
Line 61:

# Create network interface
resource "azurerm_network_interface" "nic" {
name                      = "myNIC"
location                  = "westus2"
resource_group_name       = azurerm_resource_group.rg.name
network_security_group_id = azurerm_network_security_group.nsg.id

ip_configuration {
    name                          = "myNICConfg"
    subnet_id                     = azurerm_subnet.subnet.id
    private_ip_address_allocation = "dynamic"
    public_ip_address_id          = azurerm_public_ip.publicip.id

The network_security_group_id doesn’t seem to be a part of the azurerm_network_interface resource anymore.

I haven’t quite figured out where to link the NSG but if I do I’ll update this post :slight_smile:

It looks like you need one of these:

resource "azurerm_network_interface_security_group_association" "nic-nsg" {
  network_interface_id      = azurerm_network_interface.nic.id
  network_security_group_id = azurerm_network_security_group.nsg.id

see: https://www.terraform.io/docs/providers/azurerm/r/network_interface_security_group_association.html