The module consolidates the management of DNS records in an existing or new DigitalOcaen zone. Records are supplied as input parameters of the module to keep their management in a single code block. Supported record types: A, AAAA, CNAME, MX, NS, TXT.

DNS in DigitalOcean

DNS management in DigitalOcean
$300
BUY
37
Log in to Corewide IaC registry

Once you have a Corewide Solutions Portal account, this one-time action will use your browser session to retrieve credentials:

 shellterraform login solutions.corewide.com
Provision instructions

Initialize mandatory providers:

Copy and paste into your Terraform configuration and insert the variables:

 hclmodule "tf_do_dns" {
  source  = "solutions.corewide.com/digitalocean/tf-do-dns/digitalocean"
  version = "~> 1.1.1"

  # specify module inputs here or try one of the examples below
  ...
}

Initialize the setup:

 shellterraform init
Define update strategy

Corewide DevOps team strictly follows Semantic Versioning Specification to provide our clients with products that have predictable upgrades between versions. We recommend pinning patch versions of our modules using pessimistic constraint operator (~>) to prevent breaking changes during upgrades.

To get new features during the upgrades (without breaking compatibility), use ~> 1.1 and run terraform init -upgrade

For the safest setup, use strict pinning with version = "1.1.1"

v1.1.1 released 6 months ago
New version approx. every 2 weeks

Creation of a hosted zone and DNS records:

 hclmodule "dns" {
  source  = "solutions.corewide.com/digitalocean/tf-do-dns/digitalocean"
  version = "~> 1.1"

  create_zone = true
  zone_name   = "example.com"

  records = {
    "@" = {
      type = "A"

      value = [
        "1.2.3.4",
        "1.2.3.5",
        "1.2.3.6",
        "1.2.3.7",
      ]
    }
    replica = {
      type  = "CNAME"
      ttl   = 2700
      value = ["@"]
    }
    blog = {
      type = "AAAA"
      ttl  = 3600

      value = [
        "22f9:33a8:8b1c:d77f:3408:3ccd:2dd9:35a4",
        "7e08:f9a2:0747:f787:6ef9:2985:7a18:a307",
      ]
    }
    ssl-validation = {
      type  = "TXT"
      ttl   = 600
      value = ["seiufhna;ifj0847yt4hgles4rt0w34ygh;ap98ry43w870tw4i5htg;a8pp9y3tp5wi"]
    }
    "mail.info" = {
      type     = "MX"
      value    = ["info.mail."]
      priority = 1
    }
    "mail.personal" = {
      type     = "MX"
      value    = ["personal.mail"]
      priority = 1
    }
    "board" = {
      type  = "CNAME"
      value = ["board."]
    }
    "forum" = {
      type  = "CNAME"
      value = ["forum"]
    }
  }
}

Creation of a hosted zone and one root DNS record:

 hclmodule "dns" {
  source  = "solutions.corewide.com/digitalocean/tf-do-dns/digitalocean"
  version = "~> 1.1"

  create_zone = true
  zone_name   = "example.com"

  records = {
    "@" = {
      type  = "A"
      value = ["1.2.3.4"]
    }
  }
}
Variable Description Type Default Required Sensitive
records[<key>] Name of the DNS record string yes no
zone_name The name of the DNS zone string yes no
create_zone Enable Hosted Zone creation bool false no no
records A map of DNS records to create map(object) {} no no
records[<key>].priority The priority of the record (only for MX type) number 0 no no
records[<key>].ttl Time to Live (TTL) of the record in seconds number 300 no no
records[<key>].type Record type (A, AAAA, CNAME, MX, NS, or TXT) string yes no
records[<key>].value List of values for the record list(string) yes no
Output Description Type Sensitive
records Managed DNS records attributes computed no
zone DNS zone attributes computed no
Dependency Version Kind
terraform >= 1.3 CLI
digitalocean/digitalocean ~> 2.0 provider

Not sure where to start?
Let's find your perfect match.