Documentation

esc
    Reference / DNS and domains

    DNS and domains with Terraform

    The pantechdynamics_dns_zone, pantechdynamics_dns_record and pantechdynamics_domain resources and their data sources, with examples.

    Manage Pantech DNS zones and records, and the settings of domains, with the Terraform provider.

    ResourceWhat it is
    pantechdynamics_dns_zoneA hosted zone. Reports the two name_servers to set at your registrar
    pantechdynamics_dns_recordOne record set: a name, a type, a TTL and its values
    pantechdynamics_domainA domain registered on Pantech: buying it, and its renewal, lock, privacy and name servers
    Data sourceWhat it reads
    pantechdynamics_dns_zoneA zone you already have, by id or name
    pantechdynamics_dns_recordsA zone's record sets, by zone_id, optionally only one type or name
    pantechdynamics_domainA domain you already have, by id or name
    pantechdynamics_domain_tldsThe endings Pantech sells, with their prices per year

    pantechdynamics_dns_zone

    HCL
    resource "pantechdynamics_dns_zone" "main" {
      name        = "example.com"
      description = "Marketing site"
    }
    
    output "name_servers" {
      value = pantechdynamics_dns_zone.main.name_servers
    }
    Argument
    nameRequired. The domain, in lower case without a trailing dot, such as example.com. Changing it replaces the zone and every record in it
    descriptionOptional. Changes in place
    Attribute
    iddnsz_…
    statuspending while it is created, awaiting_delegation until your registrar points at name_servers, then active. Also suspended, deleting or failed
    name_serversThe two name servers to set at the registrar
    domain_idThe Pantech domain that uses the zone, if any
    record_countRecord sets in the zone

    Apply waits until the zone has its name servers, not until it is active: delegation is done at your registrar, outside Terraform (a domain registered with pantechdynamics_domain is pointed at its zone for you). A zone not delegated within 14 days is removed and becomes failed (failure_code delegation_timeout); Terraform then plans to create it again. The first 5 live zones are free; for a zone beyond them the plan warns with its monthly price. An organization has at most 25 zones, and only an owner's or admin's key can change them.

    Destroying a zone deletes it, and Pantech stops answering for the domain at once. It needs a key with the delete scope. A zone a Pantech domain uses cannot be destroyed until the domain uses other name servers.

    pantechdynamics_dns_record

    HCL
    resource "pantechdynamics_dns_record" "www" {
      zone_id = pantechdynamics_dns_zone.main.id
      name    = "www"
      type    = "A"
      ttl     = 300
      values  = [pantechdynamics_instance.web.public_ipv4]
    }
    
    resource "pantechdynamics_dns_record" "mail" {
      zone_id = pantechdynamics_dns_zone.main.id
      name    = "@"
      type    = "MX"
      values  = ["10 mail.example.com.", "20 mail2.example.com."]
    }
    
    resource "pantechdynamics_dns_record" "internal_db" {
      zone_id       = pantechdynamics_dns_zone.main.id
      name          = "db.internal"
      type          = "A"
      values        = [pantechdynamics_database.orders.private_ip]
      allow_private = true
    }
    Argument
    zone_idRequired. Changing it replaces the record
    nameRequired. Relative to the zone: @, www, *.dev. Changing it replaces the record
    typeRequired. A, AAAA, CNAME, MX, TXT, SRV, CAA, NS or PTR. Changing it replaces the record
    valuesRequired. 1 to 100 values, in the formats of the type. Names are compared the way the DNS server stores them, so case and a trailing dot never show a change
    ttlOptional. 60 to 86,400. Default 300
    allow_privateOptional. Allow private addresses
    commentOptional. A note for yourself, up to 255 characters, not published
    Attribute
    iddnsr_…
    fqdnThe full name
    statuspending, then active within about a minute
    versionSent as If-Match, so a record someone changed outside Terraform is reported, not overwritten

    Apply waits until the record is active. In a zone still awaiting delegation a record stays pending until the zone is active, so the wait ends at once with a warning and the record is kept. A record set already in the zone with the same name and type is refused (DNS_RECORD_EXISTS): import it instead. The apex SOA and NS are Pantech's and cannot be managed. Destroying a record needs a key with the delete scope.

    pantechdynamics_domain

    HCL
    resource "pantechdynamics_domain" "main" {
      name          = "example.dev"
      years         = 1
      auto_renew    = true
      privacy       = true
      transfer_lock = true
      accept_terms  = true
    
      contact = {
        type          = "person"
        first_name    = "Ada"
        last_name     = "Obi"
        email         = "ada@example.com"
        phone         = "+234.8012345678"
        address_line1 = "1 Marina"
        city          = "Lagos"
        country_code  = "NG"
      }
    }

    The price is the ending's register price plus its renew price for each year after the first, before VAT. When your credit does not cover it, the order waits up to an hour for the difference: in US dollars your saved card is charged (a payment link appears only if your bank asks you to confirm), in naira you add credit. The apply stops meanwhile; once the order is paid, apply again and the domain is taken into state without a second order. Only an owner's or admin's key can register or change domains.

    Argument
    nameRequired. Changing it replaces the resource, which buys another domain
    contactRequired. The registrant, as in the contact object. Sensitive. Changes in place
    accept_termsRequired, true. Says you have read and accept the Domain Registration Agreement, including the registrant's rights
    yearsOptional, 1 to 10, default 1 (at most 5 for some endings, the .ng family among them, for organizations billed in naira). Used only when the domain is registered. Renew with auto-renew or the console
    auto_renewOptional. Default true
    privacyOptional. Default true. Always on for .ng endings, where false is refused at plan time
    transfer_lockOptional. Default true
    name_serversOptional. Custom name servers only: 2 to 6 host names of your own. Leave out to use Pantech DNS, which serves the domain from a pantechdynamics_dns_zone with the domain's name. Removing it points the domain back at that zone
    Attribute
    iddom_…
    statusactive once registered
    expires_atWhen the domain expires
    contact_verifiedfalse until the registrant confirms the registry's email, within 15 days
    name_server_modepantech or custom
    current_name_serversThe name servers the domain is delegated to now, Pantech DNS's or your own. Read-only
    zone_idThe Pantech DNS zone the domain is delegated to, or null. Read-only
    order_idThe registration order (dor_…). Null after an import

    To manage a domain you already have on Pantech, import it. Nothing is bought:

    Terminal
    $ terraform import pantechdynamics_domain.main dom_06gk3x9tq7m2v8r4y1c5d0zp8w

    Destroying the resource only removes it from Terraform's state. The domain stays yours and keeps renewing if auto_renew is on. Turn auto-renew off first if you want it to expire. Transfers in and out, and auth codes, are done in the console, the CLI or the API.

    Data sources

    HCL
    data "pantechdynamics_dns_zone" "main" {
      name = "example.com"
    }
    
    data "pantechdynamics_dns_records" "mail" {
      zone_id = data.pantechdynamics_dns_zone.main.id
      type    = "MX"
    }
    
    data "pantechdynamics_domain" "main" {
      name = "example.com"
    }
    
    data "pantechdynamics_domain_tlds" "all" {}
    
    output "dev_price_per_year" {
      value = [for t in data.pantechdynamics_domain_tlds.all.tlds : t.register_minor if t.tld == "dev"]
    }

    pantechdynamics_dns_records lists the zone's record sets by name then type, in records, including the apex SOA and NS (managed = true). Leave type and name out to list them all.

    Prices are integers in minor units of currency, per year.

    Import

    Terminal
    $ terraform import pantechdynamics_dns_zone.main dnsz_06gk3x9tq7m2v8r4y1c5d0zp8w$ terraform import pantechdynamics_dns_record.www dnsz_06gk3x9tq7m2v8r4y1c5d0zp8w/dnsr_07hm4y0ur8n3w9s5z2d6e1aq9x

    A record is imported by its zone's id and its own, separated by /, or by its zone's id, name and type:

    Terminal
    $ terraform import pantechdynamics_dns_record.mx dnsz_06gk3x9tq7m2v8r4y1c5d0zp8w/@/MX

    @ is the apex.

    Was this page helpful?

    Updated