Verified Commit 38dc2292 authored by Frederik Schwan's avatar Frederik Schwan
Browse files

improve terraform handling of virtual machine domains

machine.domain has been an mandatory attribute which creates
<domain>.archlinux.org entries automagically. For migrations this can be
a problem if <domain>.archlinux.org supposed to point to a different
machine. Adding the new machine with the same domain leads to additional
DNS entries. The DNS ends up pointing to both machines in this case.
By making the domain attribute optional for machines, we allow the new
machines to be created without any domain pointing to them.
parent d23d14ca
......@@ -36,7 +36,7 @@ locals {
#
# Valid parameters are:
# - server_type (mandatory)
# - domain (mandatory)
# - domain (optional, creates dns entry <domain>.archlinux.org pointing to the machine)
# - ttl (optional, applies to the dns entries)
# - zone (optionel, required for pkgbuild.com machines)
#
......@@ -81,7 +81,6 @@ locals {
}
"lists.archlinux.org" = {
server_type = "cx11"
domain = "lists"
}
"mail.archlinux.org" = {
server_type = "cx11"
......
......@@ -116,7 +116,9 @@ resource "hcloud_server" "machine" {
}
resource "hetznerdns_record" "machine_a" {
for_each = local.machines
for_each = {
for name, machine in local.machines : name => machine if can(machine.domain)
}
zone_id = lookup(local.machines[each.key], "zone", hetznerdns_zone.archlinux.id)
name = each.value.domain
......@@ -126,7 +128,9 @@ resource "hetznerdns_record" "machine_a" {
}
resource "hetznerdns_record" "machine_aaaa" {
for_each = local.machines
for_each = {
for name, machine in local.machines : name => machine if can(machine.domain)
}
zone_id = lookup(local.machines[each.key], "zone", hetznerdns_zone.archlinux.id)
name = each.value.domain
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment