DNS Zone

Overview

The DNS Zone module contains two types of builders - dnsZone, used to create DNS Zones, and ___Record (like cnameRecord, aRecord, ..), used to create DNS Records sets. It supports most record types (except SOA, SRV and CAA) and has specific builders for every record type.

  • DNS Zone (Microsoft.Network/dnsZones)
  • A Record (Microsoft.Network/dnsZones/A)
  • AAAA Record (Microsoft.Network/dnsZones/AAAA)
  • CNAME Record (Microsoft.Network/dnsZones/CNAME)
  • TXT Record (Microsoft.Network/dnsZones/TXT)
  • MX Record (Microsoft.Network/dnsZones/MX)
  • NS Record (Microsoft.Network/dnsZones/NS)
  • PTR Record (Microsoft.Network/dnsZones/PTR)

TODO

The following items are currently unsupported:

  • SOA records
  • SRV records
  • CAA records
  • Private Zone (untested)
  • Virtual network support for Private Zones
  • Tags

DNS Zone Builder Keywords

KeywordPurpose
nameSets the name of the domain.
zone_typeSets the zone type.
add_recordsAdds DNS Zone records (see below).

Each Record type has its own custom builder. All builders share the following common keywords:

KeywordPurpose
nameSets the name of the record set (default to @).
ttlSets the time-to-live of the record set.

In addition, each record builder has its own custom keywords:

A Record Builder Keywords

KeywordPurpose
add_ipv4_addressesAdd IPv4 addresses to this record set.
target_resourceA reference to an azure resource from where the dns resource value is taken.

AAAA Record Builder Keywords

KeywordPurpose
add_ipv6_addressesAdd IPv6 addresses to this record set.
target_resourceA reference to an azure resource from where the dns resource value is taken.

CNAME Record Builder Keywords

KeywordPurpose
cnameSets the canonical name for this CNAME record.
target_resourceA reference to an azure resource from where the dns resource value is taken.

TXT Record Builder Keywords

KeywordPurpose
add_valuesAdd TXT values to this record set.

MX Record Builder Keywords

KeywordPurpose
add_valuesAdd MX values to the record set.

NS Record Builder Keywords

KeywordPurpose
add_nsd_namesAdd NS values to this record set.

PTR Record Builder Keywords

KeywordPurpose
add_ptrd_namesAdd PTR names to this record set.

Example

#r @"./libs/Newtonsoft.Json.dll"
#r @"../../src/Farmer/bin/Debug/netstandard2.0/Farmer.dll"

open Farmer
open Farmer.Builders

let dns = dnsZone {
    name "farmer.com"
    zone_type Dns.Public
    add_records [
        cnameRecord {
            name "www2"
            ttl 3600
            cname "farmer.github.com"
        }
        aRecord {
            ttl 7200
            add_ipv4_addresses [ "192.168.0.1"; "192.168.0.2" ]
        }
        aaaaRecord {
            ttl 7200
            add_ipv6_addresses [ "100:100:100:100" ]
        }
        txtRecord {
            ttl 3600
            add_values [ "v=spf1 include:spf.protection.outlook.com -all" ]
        }
        mxRecord {
            ttl 7200
            add_values [
                0, "farmer-com.mail.protection.outlook.com";
                1, "farmer2-com.mail.protection.outlook.com";
            ]
        }
    ]
}

let deployment = arm {
    location Location.NorthEurope
    add_resource dns
}

deployment
|> Writer.quickWrite "dns-example"