chore: refined control script

This commit is contained in:
2026-07-21 16:53:15 +01:00
parent aa3ea39ddf
commit 7ebd02f6b8
15 changed files with 144 additions and 30 deletions
+20 -6
View File
@@ -14,15 +14,29 @@ resource "hcloud_zone" "this" {
}
}
resource "hcloud_zone_rrset" "a" {
for_each = { for r in var.records : "${r.zone}/${r.name}" => r }
locals {
# Group flat var.records entries by zone/name/type into one set of values
# each, since a Hetzner RRSet is keyed on (zone, name, type) and can hold
# several values (e.g. an SPF and a google-site-verification TXT both live
# under the same "@" TXT RRSet).
rrsets = {
for key, items in { for r in var.records : "${r.zone}/${r.name}/${r.type}" => r... } : key => {
zone = items[0].zone
name = items[0].name
type = items[0].type
ttl = items[0].ttl
values = [for i in items : i.value]
}
}
}
resource "hcloud_zone_rrset" "this" {
for_each = local.rrsets
zone = hcloud_zone.this[each.value.zone].id
name = each.value.name
type = "A"
type = each.value.type
ttl = each.value.ttl
records = [
{ value = each.value.value }
]
records = [for v in each.value.values : { value = v }]
}