Skip to content

Private DNS A Record

Private DNS A records are defined with the private_dns_a_record variable. Each record gets its IP addresses from exactly one source: a reference to another resource managed in this repository (by key), or an explicit list of IP addresses.

Private DNS A Record Variables Example

private_dns_a_record = {
    intranet = {
        resource_group = "network"
        zone = "sapphirehealth"

        # Resolve the IP from a load balancer frontend
        load_balancer = {
            key = "web"
            frontend_ip_configuration = "web_fe_ip"
        }
    }
    portal = {
        resource_group = "network"
        zone = "sapphirehealth"

        # Resolve the IP from an application gateway frontend
        application_gateway = {
            key = "dmz"
            frontend_ip_configuration = "appGwPrivateFrontendIp"
        }
    }
    smtp = {
        resource_group = "network"
        zone = "sapphirehealth"

        # Resolve the IP from a container group
        container_group = "smtp"
    }
    legacy = {
        resource_group = "network"
        zone = "sapphirehealth"
        ttl = 60

        # Or specify the IP addresses directly
        records = ["10.10.4.10"]
    }
}

Private DNS A Record Variable Reference

Field Type Description Default
name string Record name. Composed from name_prefixes/name_suffixes and the map key when omitted. null
resource_group string Key of the rgs entry the record is created in. Required
zone string Key of the private_dns_zone entry the record is created in. Required
ttl number Record TTL in seconds. 300
container_group string Key of a container_group entry. Resolves to the container group's IP address. null
public_ip string Key of a public_ip entry. Resolves to the public IP address. null
network_interface string Key of a network_interface entry. Resolves to the NIC's primary private IP address. null
load_balancer object Reference to a load balancer frontend, see below. null
application_gateway object Reference to an application gateway frontend, see below. null
records list(string) Explicit IP addresses. null
tags map(string) Merged with default_tags. {}

Exactly one IP source must be set per record — one of container_group, public_ip, network_interface, load_balancer, application_gateway, or records. Setting more than one (or none) fails validation at plan time.

load_balancer / application_gateway Reference

Both objects have the same shape:

Field Type Description Default
key string Key of the load_balancer / agws entry. Required
frontend_ip_configuration string Name of the frontend IP configuration on that resource whose private IP the record resolves to. Required

frontend_ip_configuration is matched against the frontend's name. On the load balancer module, that is the frontend entry's name field or, when name is not set, its map key. On the application gateway module, it is the frontend entry's name field, which is always set explicitly.

Notes

Note: The private IP is read from the module output at apply time, so frontends using private_ip_address_allocation = "Dynamic" resolve correctly — the record picks up whatever address Azure assigns.

Note: Frontends without a private IP (e.g. a public-only frontend) resolve to an empty record set. Point the record at a frontend that has a subnet/private IP configured.