Table of Contents

Class DigitalOceanDns

Namespace
Fabricator.Resources
Assembly
Fabricator.Resources.dll

Resources managing the DNS records of the domains hosted by DigitalOcean DNS.

[CompilationMapping(SourceConstructFlags.ObjectType)]
public class DigitalOceanDns
Inheritance
DigitalOceanDns
Inherited Members

Examples

To make example.com have a single TXT record TXT @ mytext, with the token stored in a KeePass database (see the FVNever.Fabricator.Secrets.KeePass package):

open Fabricator.Core
open Fabricator.Resources
open Fabricator.Secrets.KeePass
open TruePath

let secrets = KeePassSecretStore(AbsolutePath @"C:\Secrets\infra.kdbx")
let dns = DigitalOceanDns.Domain(
    "example.com",
    { Store = secrets; Name = SecretName "digitalocean-token" },
    [
        DigitalOceanDns.Record("TXT", "@", "mytext")
    ]
)

Remarks

Domain(string, SecretRef, IEnumerable<DigitalOceanDnsRecord>, FSharpOption<IEnumerable<Resource>>?) manages all the DNS records of a domain: when applied, it updates the changed records in place, deletes the records not declared, and creates the missing ones. The SOA and NS records of the domain itself (@) are managed by DigitalOcean and are ignored. The changes are shown as a diff of the records in the zone file format.

The resources require a DigitalOcean API token, taken from a secret store. Use a personal access token: generate it in the DigitalOcean control panel, in API → Tokens → Generate New Token (https://cloud.digitalocean.com/account/api/tokens). Give it either full access, or the custom scopes domain:read, domain:create, and domain:delete.

Methods

ConcurrencyGroup(string)

The concurrency group of the resources managing the records of the specified domain.

public static ConcurrencyGroup ConcurrencyGroup(string domain)

Parameters

domain string

The domain name.

Returns

ConcurrencyGroup

Domain(string, SecretRef, IEnumerable<DigitalOceanDnsRecord>, FSharpOption<IEnumerable<Resource>>?)

Creates a resource managing all the DNS records of a domain hosted by DigitalOcean DNS.

public static Resource Domain(string domain, SecretRef token, IEnumerable<DigitalOceanDnsRecord> records, FSharpOption<IEnumerable<Resource>>? dependsOn)

Parameters

domain string

The domain name, e.g. example.com. It should already be added to DigitalOcean.

token SecretRef

The DigitalOcean API token in a secret store.

records IEnumerable<DigitalOceanDnsRecord>

All the records the domain should have, created via Record(string, string, string, FSharpOption<int>?, FSharpOption<int>?, FSharpOption<int>?, FSharpOption<int>?, FSharpOption<int>?, FSharpOption<string>?).

dependsOn FSharpOption<IEnumerable<Resource>>

The resources this resource depends on.

Returns

Resource

A resource managing the DNS records of the domain.

Remarks

The resource owns all the records of the domain: when applied, it deletes the records not passed in records, and creates the missing ones. A changed record of the same type and name (e.g. one with another TTL or data) is updated in place. The only exceptions are the SOA and NS records of the domain itself (@): DigitalOcean manages them, so the resource ignores them, and doesn't allow to declare them.

The changes are shown as a diff of the records in the zone file format, one record per line. Every update, deletion, and creation is written to the log before it is executed.

The token is required for both the check and the application. See DigitalOceanDns for how to get it, and for an example.

Throws an ArgumentException listing all the invalid records if any of the records is the SOA or NS record of the domain itself, has an unsupported type, a name that is not relative to the domain, empty data, a host name that is not fully qualified, an invalid IP address (A records require IPv4 addresses in the dotted-decimal form, AAAA records require IPv6 addresses), a TTL less than 30 seconds, misses a field required by its type or has a field not applicable to it, has an unsupported CAA tag, or is declared several times.

Record(string, string, string, FSharpOption<int>?, FSharpOption<int>?, FSharpOption<int>?, FSharpOption<int>?, FSharpOption<int>?, FSharpOption<string>?)

public static DigitalOceanDnsRecord Record(string recordType, string name, string data, FSharpOption<int>? ttl, FSharpOption<int>? priority, FSharpOption<int>? port, FSharpOption<int>? weight, FSharpOption<int>? flags, FSharpOption<string>? tag)

Parameters

recordType string

The record type: A, AAAA, CAA, CNAME, MX, NS, SRV, or TXT.

name string

The name of the record, relative to the domain; @ denotes the domain itself.

data string

The value of the record. Host names must be fully qualified and end with a dot, e.g. mail.example.com., or be @ for the domain itself.

ttl FSharpOption<int>

The time to live of the record, in seconds. 1800 by default.

priority FSharpOption<int>

The priority, required for MX and SRV records.

port FSharpOption<int>

The port, required for SRV records.

weight FSharpOption<int>

The weight, required for SRV records.

flags FSharpOption<int>

The flags (0–255), required for CAA records.

tag FSharpOption<string>

The tag (issue, issuewild, or iodef), required for CAA records.

Returns

DigitalOceanDnsRecord