Hetzner's legacy DNS console (dns.hetzner.com) and its old DNS API have been permanently shut down. All DNS zone management has been migrated entirely to the main Hetzner Cloud Console. Since I hadn't made any changes in the last couple of months I was simply not affected by that change until very recently. So, this change drops the 3rd-party provider I had used previously and now applies the official `hcloud`-provider. The migrations was a bit of a hassle, because I had to manually remove the obsolete references from the Tofu-state. Then I checked the migrated sources and decided to simply drop the migrated DNS-zones altogether and simply run `tofu apply` once more.
29 lines
645 B
HCL
29 lines
645 B
HCL
resource "hcloud_zone" "this" {
|
|
name = var.zone
|
|
mode = "primary"
|
|
ttl = var.zone_ttl
|
|
}
|
|
|
|
locals {
|
|
records = nonsensitive({
|
|
for record in var.records : "${record.type}#${record.name}#${md5(record.value)}" => {
|
|
for key, value in record : key => value
|
|
}
|
|
})
|
|
}
|
|
|
|
resource "hcloud_zone_rrset" "this" {
|
|
for_each = local.records
|
|
zone = hcloud_zone.this.name
|
|
name = each.value.name
|
|
type = each.value.type
|
|
records = [{
|
|
value = (each.value.type == "TXT"
|
|
? "\"${join("\" \"", [for c in chunklist(split("", each.value.value), 255) : join("", c)])}\""
|
|
: each.value.value
|
|
)
|
|
}]
|
|
ttl = each.value.ttl
|
|
}
|
|
|