refactor: Support multiple mx records per domain

This commit is contained in:
2026-03-14 16:47:40 +01:00
parent c30b2e7d53
commit ae3e80a783
4 changed files with 32 additions and 38 deletions
+3 -4
View File
@@ -29,17 +29,16 @@ resource "hcloud_zone_rrset" "aaaa" {
}
resource "hcloud_zone_rrset" "mx" {
count = var.hasMXRecord ? 1 : 0
count = length(var.mxRecords) > 0 ? 1: 0
zone = var.domain
name = var.subdomain != "" ? var.subdomain : "@"
type = "MX"
ttl = 3600
change_protection = true
records = [
{ value = format("%s %s.", var.mxPrio, var.hostName) }
for record in var.mxRecords:
{ value = format("%s %s.", record.prio, record.hostname) }
]
}
+6 -13
View File
@@ -17,24 +17,17 @@ variable "subdomain" {
default = ""
}
variable "hasMXRecord" {
type = bool
default = false
}
variable "hasIPRecords" {
type = bool
default = true
}
variable "hostName" {
type = string
default = ""
}
variable "mxPrio" {
type = number
default = 0
variable "mxRecords" {
type = list(object({
hostname: string,
prio: number
}))
default = []
}
variable "txtValues" {
-1
View File
@@ -28,7 +28,6 @@ module "at_proto_domain" {
domain = hcloud_zone.twomartens_de.name
subdomain = "_atproto"
hasIPRecords = false
hasMXRecord = false
txtValues = [
"did=did:plc:dboupmredm5i3vktwci6nbip"
]
+22 -19
View File
@@ -1,13 +1,14 @@
// Identity management
module "keycloak_domain" {
source = "./modules/domain"
domain = hcloud_zone.twomartens_de.name
subdomain = "id"
ipv4 = "95.143.172.184"
ipv6 = "2001:1a50:11:0:98b3:92ff:fe3e:bba1"
hasMXRecord = true
hostName = "monoceres.uberspace.de"
mxPrio = 0
source = "./modules/domain"
domain = hcloud_zone.twomartens_de.name
subdomain = "id"
ipv4 = "95.143.172.184"
ipv6 = "2001:1a50:11:0:98b3:92ff:fe3e:bba1"
mxRecords = [{
hostname : "monoceres.uberspace.de"
prio : 0
}]
txtValues = ["v=spf1 include:spf.uberspace.de ~all"]
uberspaceDomainKey = "v=DKIM1;t=s;n=core;p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqs3bFL8W77z7VJHCFbsJ3o68Y1uBbVsbIS1y35CMfRv6wp7si7aIG2ZeKqzdh2dTMsvtvSMaYVq1gT/EtRmTbU/BYC21ff8sqcVqn/ll5nNsk5jKWXTYAlTQp4LBQN7icw94ZNGr5/SDYcnv2nsBYFf2GUviObWXGHX4RaBFNj9NVUNWNin/HicvW+LsbfYq37QtlhjmUn9K96VCwKcTV1mx+Ek0osErYefcOVNawqWIlVRQDLkHZhk1StLsOpRqV+qEjhzTk4n4ZiNtLJG1D9CpHl24d5DKsQDyVFdEfqHimFTSNgiitlkuXg+i+NMiRA9G3gNJtvw8uvfN8f+stQIDAQAB"
}
@@ -49,14 +50,15 @@ module "statping_domain" {
// Personal Website
module "personal_website_domain" {
source = "./modules/domain"
domain = hcloud_zone.twomartens_de.name
subdomain = ""
ipv4 = "185.26.156.65"
ipv6 = "2a00:d0c0:200:0:b9:1a:9c:40"
hasMXRecord = true
hostName = "howell.uberspace.de"
mxPrio = 0
source = "./modules/domain"
domain = hcloud_zone.twomartens_de.name
subdomain = ""
ipv4 = "185.26.156.65"
ipv6 = "2a00:d0c0:200:0:b9:1a:9c:40"
mxRecords = [{
hostname : "howell.uberspace.de"
prio : 0
}]
txtValues = [
"openai-domain-verification=dv-EcR0SCNAnUYVquVZVgb21Wdt",
"google-site-verification=nUFiHQFxBpBMdX96ELH3TcfyIfXf2ZlwMFYtXjVq5lo",
@@ -86,9 +88,10 @@ module "appreview_domain" {
subdomain = "appreview"
hasIPRecords = false
hasMXRecord = true
hostName = "wolf.uberspace.de"
mxPrio = 0
mxRecords = [{
hostname : "wolf.uberspace.de"
prio : 0
}]
txtValues = [
"v=spf1 include:spf.uberspace.de ~all"
]