Review Azure Container Instances network exposure

Keep internal workloads within approved virtual networks and required communication paths.

Description

Choose a Private IP for an Azure Container Instances (ACI) group that serves only internal clients. Use Public for a public service or None when the group needs no IP address.

Potential impact

With a public IP, exposure depends on listening ports and access rules. Moving to a private IP can interrupt clients if routes or DNS are missing.

Remediation

Set ip_address_type = "Private" and point subnet_ids to a dedicated subnet delegated to ACI. Allow only the required sources and ports in the NSG. Check DNS, routing, application authentication and TLS. If the group needs outbound internet access, configure a NAT gateway on the subnet.

Examples

The excerpts omit listening ports and network paths. Changing the IP type replaces the group. Review the Terraform plan and test the deployed endpoint from an internal client.

Before

hcl
resource "azurerm_container_group" "example" {
  name                = "example-container-group"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  os_type             = "Linux"
  ip_address_type     = "Public"

  container {
    name   = "app"
    image  = "nginx:stable"
    cpu    = 1
    memory = 1
  }
}

After

hcl
resource "azurerm_container_group" "example" {
  name                = "example-container-group"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  os_type             = "Linux"
  ip_address_type     = "Private"
  subnet_ids          = [azurerm_subnet.aci.id]

  container {
    name   = "app"
    image  = "nginx:stable"
    cpu    = 1
    memory = 1
  }
}

References