The module consolidates the management of DNS records in an existing or new GCP Cloud DNS 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 GCP Cloud DNS

DNS management in GCP Cloud DNS
$300
BUY
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_gcp_dns" {
  source  = "solutions.corewide.com/google-cloud/tf-gcp-dns/google"
  version = "~> 1.0.0"

  # 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.0 and run terraform init -upgrade

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

v1.0.0 released 6 months, 4 weeks ago

Custom configuration setup with a new DNS zone and multiple records with different configurations:

 hclmodule "dns" {
  source  = "solutions.corewide.com/google-cloud/tf-gcp-dns/google"
  version = "~> 1.0"

  zone_identifier = "example"
  zone_name       = "example.com"
  create_zone     = true

  records = {
    "@" = {
      type  = "A"
      value = ["10.0.1.10"]
    }
    "foo" = {
      type  = "A"
      value = ["10.0.4.20"]
      ttl   = 7200
    }
    "www" = {
      type  = "CNAME"
      value = ["example.com."]
    }
    "mail" = {
      type  = "MX"
      value = ["1 example.com."]
    }
    "txt" = {
      type  = "TXT"
      value = ["\\"My\\" \\"txt\\" \\"note\\""]
    }
    "ns" = {
      type  = "NS"
      value = ["foo.ns.site.com."]
    }
    "v6" = {
      type = "AAAA"

      value = [
        "2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF",
        "2001:0000:130F:0000:0000:09C0:876A:130B",
      ]
    }
  }
}

Minimal setup with a single record in an existing DNS zone:

 hclmodule "dns" {
  source  = "solutions.corewide.com/google-cloud/tf-gcp-dns/google"
  version = "~> 1.0"

  zone_identifier = "example-com"

  records = {
    "@" = {
      type  = "A"
      value = ["10.0.1.10"]
    }
  }
}
Variable Description Type Default Required Sensitive
records[<key>] Name of the DNS record string yes no
zone_identifier The hosted DNS zone resource name string yes no
zone_name The hosted DNS zone name to create records in string yes no
create_zone Enable hosted zone creation bool false no no
records DNS records configuration map(object) {} no no
records[<key>].ttl The time to live of the record number 300 no no
records[<key>].type The type of the record. Possible values are: A, AAAA, CNAME, MX, NS and TXT string yes no
records[<key>].value The content of the record list(string) yes no
zone_description The hosted DNS zone description string Managed by Terraform no no
Output Description Type Sensitive
records DNS records resource attributes computed no
zone Hosted DNS zone attributes computed no
Dependency Version Kind
terraform >= 1.3 CLI
hashicorp/google ~> 6.3 provider

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