Network Interface should have a Network Security Group attached

High Azure General networkinterfaces-network-interface-network-securi

Applies to

  • Microsoft.Network/networkInterfaces

What CGPulse checks

A resource passes this rule when hasNetworkSecurityGroup must equal true. Anything else is reported as a finding with the evaluated property value attached as evidence.

How to fix it

Attach a Network Security Group to control traffic with security rules. In Azure Portal: NIC > Network Security Group > associate an NSG. See: https://learn.microsoft.com/en-us/azure/virtual-network/network-security-groups-overview

CLI

az network nic update --ids "{id}" --network-security-group "<nsg-id>"

Bicep

resource nic 'Microsoft.Network/networkInterfaces@2024-01-01' = {{
  name: '{name}'
  location: resourceGroup().location
  properties: {{
    ipConfigurations: [
      {{
        name: 'ipconfig1'
        properties: {{
          subnet: {{
            id: subnetId
          }}
        }}
      }}
    ]
    networkSecurityGroup: {{
      id: 'var.nsg_id'
    }}
  }}
}}

Terraform

resource "azurerm_network_interface" "{name}" {
  name                = "{name}"
  resource_group_name = "{rg}"
  location            = var.location
  ip_configuration {
    name                          = "ipconfig1"
    subnet_id                     = var.subnet_id
    private_ip_address_allocation = "Dynamic"
  }
}
resource "azurerm_network_interface_security_group_association" "{name}" {
  network_interface_id      = "{id}"
  network_security_group_id = var.nsg_id
}

Compliance frameworks

Is your environment compliant with this rule?

CGPulse checks it — and 621 others — against your Azure and AWS accounts with read-only access.

Run a free scan

Related Azure rules

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please reload the page.