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.
| Resource | What it is |
|---|---|
pantechdynamics_dns_zone | A hosted zone. Reports the two name_servers to set at your registrar |
pantechdynamics_dns_record | One record set: a name, a type, a TTL and its values |
pantechdynamics_domain | A domain registered on Pantech: buying it, and its renewal, lock, privacy and name servers |
| Data source | What it reads |
|---|---|
pantechdynamics_dns_zone | A zone you already have, by id or name |
pantechdynamics_dns_records | A zone's record sets, by zone_id, optionally only one type or name |
pantechdynamics_domain | A domain you already have, by id or name |
pantechdynamics_domain_tlds | The endings Pantech sells, with their prices per year |
pantechdynamics_dns_zone
resource "pantechdynamics_dns_zone" "main" {
name = "example.com"
description = "Marketing site"
}
output "name_servers" {
value = pantechdynamics_dns_zone.main.name_servers
}| Argument | |
|---|---|
name | Required. The domain, in lower case without a trailing dot, such as example.com. Changing it replaces the zone and every record in it |
description | Optional. Changes in place |
| Attribute | |
|---|---|
id | dnsz_… |
status | pending while it is created, awaiting_delegation until your registrar points at name_servers, then active. Also suspended, deleting or failed |
name_servers | The two name servers to set at the registrar |
domain_id | The Pantech domain that uses the zone, if any |
record_count | Record 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
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_id | Required. Changing it replaces the record |
name | Required. Relative to the zone: @, www, *.dev. Changing it replaces the record |
type | Required. A, AAAA, CNAME, MX, TXT, SRV, CAA, NS or PTR. Changing it replaces the record |
values | Required. 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 |
ttl | Optional. 60 to 86,400. Default 300 |
allow_private | Optional. Allow private addresses |
comment | Optional. A note for yourself, up to 255 characters, not published |
| Attribute | |
|---|---|
id | dnsr_… |
fqdn | The full name |
status | pending, then active within about a minute |
version | Sent 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
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 | |
|---|---|
name | Required. Changing it replaces the resource, which buys another domain |
contact | Required. The registrant, as in the contact object. Sensitive. Changes in place |
accept_terms | Required, true. Says you have read and accept the Domain Registration Agreement, including the registrant's rights |
years | Optional, 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_renew | Optional. Default true |
privacy | Optional. Default true. Always on for .ng endings, where false is refused at plan time |
transfer_lock | Optional. Default true |
name_servers | Optional. 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 | |
|---|---|
id | dom_… |
status | active once registered |
expires_at | When the domain expires |
contact_verified | false until the registrant confirms the registry's email, within 15 days |
name_server_mode | pantech or custom |
current_name_servers | The name servers the domain is delegated to now, Pantech DNS's or your own. Read-only |
zone_id | The Pantech DNS zone the domain is delegated to, or null. Read-only |
order_id | The registration order (dor_…). Null after an import |
To manage a domain you already have on Pantech, import it. Nothing is bought:
$ terraform import pantechdynamics_domain.main dom_06gk3x9tq7m2v8r4y1c5d0zp8wDestroying 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
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
$ terraform import pantechdynamics_dns_zone.main dnsz_06gk3x9tq7m2v8r4y1c5d0zp8w$ terraform import pantechdynamics_dns_record.www dnsz_06gk3x9tq7m2v8r4y1c5d0zp8w/dnsr_07hm4y0ur8n3w9s5z2d6e1aq9xA record is imported by its zone's id and its own, separated by /, or by its zone's id, name and type:
$ terraform import pantechdynamics_dns_record.mx dnsz_06gk3x9tq7m2v8r4y1c5d0zp8w/@/MX@ is the apex.