Refactor DNS-config to make it easier to maintain
This commit is contained in:
97
dns.tf
97
dns.tf
@@ -1,79 +1,88 @@
|
||||
locals {
|
||||
// gmail had a different dns-setting in the past,
|
||||
// but they claim it's still totally valid for old installations
|
||||
// they even guarantee to keep it valid in future
|
||||
// see: https://support.google.com/a/answer/174125?hl=en#zippy=%2Cgoogle-workspace-legacy-version-before
|
||||
dns_gmail_until_april_2023 = [
|
||||
{ name = "@", ttl = var.gmail_dns_default_ttl, type = "MX", value = "1 aspmx.l.google.com." },
|
||||
{ name = "@", ttl = var.gmail_dns_default_ttl, type = "MX", value = "5 alt1.aspmx.l.google.com." },
|
||||
{ name = "@", ttl = var.gmail_dns_default_ttl, type = "MX", value = "5 alt2.aspmx.l.google.com." },
|
||||
{ name = "@", ttl = var.gmail_dns_default_ttl, type = "MX", value = "10 alt3.aspmx.l.google.com." },
|
||||
{ name = "@", ttl = var.gmail_dns_default_ttl, type = "MX", value = "10 alt1.aspmx.l.google.com." },
|
||||
{ name = "@", ttl = var.gmail_dns_default_ttl, type = "TXT", value = "v=spf1 include:_spf.google.com a mx ~all" },
|
||||
]
|
||||
dns_gmail_starting_april_2023 = [
|
||||
{ name = "@", ttl = var.gmail_dns_default_ttl, type = "MX", value = "1 smtp.google.com." },
|
||||
{ name = "@", ttl = var.gmail_dns_default_ttl, type = "TXT", value = "v=spf1 include:_spf.google.com a mx ~all" },
|
||||
]
|
||||
dns_website_default = [
|
||||
{ name = "@", ttl = 900, type = "A", value = "62.138.6.205" },
|
||||
{ name = "*", ttl = 900, type = "A", value = "62.138.6.205" },
|
||||
]
|
||||
}
|
||||
|
||||
module "dns_goperte_de" {
|
||||
source = "./dns"
|
||||
zone = "goperte.de"
|
||||
records = local.dns_website_default
|
||||
zone_ttl = 900
|
||||
records = [
|
||||
{ name = "@", type = "A", value = "62.138.6.205" },
|
||||
{ name = "*", type = "A", value = "62.138.6.205" },
|
||||
]
|
||||
}
|
||||
|
||||
module "dns_nehrke_info" {
|
||||
source = "./dns"
|
||||
zone = "nehrke.info"
|
||||
records = concat(
|
||||
local.dns_website_default,
|
||||
[
|
||||
{ name = "_dmarc", ttl = var.gmail_dns_default_ttl, type = "TXT", value = "v=DMARC1; p=none;" },
|
||||
{ name = "google._domainkey", ttl = var.gmail_dns_default_ttl, type = "TXT", value = var.google_dkim["nehrke.info"] }
|
||||
],
|
||||
local.dns_gmail_until_april_2023,
|
||||
)
|
||||
zone_ttl = 3600
|
||||
records = [
|
||||
{ name = "@", ttl = 900, type = "A", value = "62.138.6.205" },
|
||||
{ name = "*", ttl = 900, type = "A", value = "62.138.6.205" },
|
||||
# TODO: update smtp-config, see https://support.google.com/a/answer/174125?hl=en#zippy=%2Cgoogle-workspace-legacy-version-before
|
||||
{ name = "@", type = "MX", value = "1 aspmx.l.google.com." },
|
||||
{ name = "@", type = "MX", value = "5 alt1.aspmx.l.google.com." },
|
||||
{ name = "@", type = "MX", value = "5 alt2.aspmx.l.google.com." },
|
||||
{ name = "@", type = "MX", value = "10 alt3.aspmx.l.google.com." },
|
||||
{ name = "@", type = "MX", value = "10 alt1.aspmx.l.google.com." },
|
||||
{ name = "@", type = "TXT", value = "v=spf1 include:_spf.google.com a mx ~all" },
|
||||
{ name = "_dmarc", type = "TXT", value = "v=DMARC1; p=none;" },
|
||||
{ name = "google._domainkey", type = "TXT", value = var.nehrke_info_dkim },
|
||||
]
|
||||
}
|
||||
|
||||
module "dns_sozpaedil_net" {
|
||||
source = "./dns"
|
||||
zone = "sozpaedil.net"
|
||||
records = concat(
|
||||
local.dns_website_default,
|
||||
[
|
||||
{ name = "_dmarc", ttl = var.gmail_dns_default_ttl, type = "TXT", value = "v=DMARC1; p=none;" },
|
||||
{ name = "google._domainkey", ttl = var.gmail_dns_default_ttl, type = "TXT", value = var.google_dkim["sozpaedil.net"] }
|
||||
],
|
||||
local.dns_gmail_until_april_2023,
|
||||
)
|
||||
zone_ttl = 3600
|
||||
records = [
|
||||
{ name = "@", ttl = 900, type = "A", value = "62.138.6.205" },
|
||||
{ name = "*", ttl = 900, type = "A", value = "62.138.6.205" },
|
||||
# TODO: update smtp-config, see https://support.google.com/a/answer/174125?hl=en#zippy=%2Cgoogle-workspace-legacy-version-before
|
||||
{ name = "@", type = "MX", value = "1 aspmx.l.google.com." },
|
||||
{ name = "@", type = "MX", value = "5 alt1.aspmx.l.google.com." },
|
||||
{ name = "@", type = "MX", value = "5 alt2.aspmx.l.google.com." },
|
||||
{ name = "@", type = "MX", value = "10 alt3.aspmx.l.google.com." },
|
||||
{ name = "@", type = "MX", value = "10 alt1.aspmx.l.google.com." },
|
||||
{ name = "@", type = "TXT", value = "v=spf1 include:_spf.google.com a mx ~all" },
|
||||
{ name = "_dmarc", type = "TXT", value = "v=DMARC1; p=none;" },
|
||||
{ name = "google._domainkey", type = "TXT", value = var.sozpaedil_net_dkim },
|
||||
]
|
||||
}
|
||||
|
||||
module "dns_tovot_de" {
|
||||
source = "./dns"
|
||||
zone = "tovot.de"
|
||||
records = local.dns_website_default
|
||||
zone_ttl = 900
|
||||
records = [
|
||||
{ name = "@", type = "A", value = "62.138.6.205" },
|
||||
{ name = "*", type = "A", value = "62.138.6.205" },
|
||||
]
|
||||
}
|
||||
|
||||
module "dns_tovot_net" {
|
||||
source = "./dns"
|
||||
zone = "tovot.net"
|
||||
records = local.dns_website_default
|
||||
zone_ttl = 900
|
||||
records = [
|
||||
{ name = "@", type = "A", value = "62.138.6.205" },
|
||||
{ name = "*", type = "A", value = "62.138.6.205" },
|
||||
]
|
||||
}
|
||||
|
||||
module "dns_tovot_org" {
|
||||
source = "./dns"
|
||||
zone = "tovot.org"
|
||||
records = local.dns_website_default
|
||||
zone_ttl = 900
|
||||
records = [
|
||||
{ name = "@", type = "A", value = "62.138.6.205" },
|
||||
{ name = "*", type = "A", value = "62.138.6.205" },
|
||||
]
|
||||
}
|
||||
|
||||
module "dns_xn--alleingnger-r8a_de" {
|
||||
source = "./dns"
|
||||
zone = "xn--alleingnger-r8a.de"
|
||||
records = local.dns_website_default
|
||||
zone_ttl = 900
|
||||
records = [
|
||||
{ name = "@", type = "A", value = "62.138.6.205" },
|
||||
{ name = "*", type = "A", value = "62.138.6.205" },
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ resource "hetznerdns_zone" "this" {
|
||||
}
|
||||
|
||||
locals {
|
||||
records = {
|
||||
records = nonsensitive({
|
||||
for record in var.records : "${record.type}#${record.name}#${md5(record.value)}" => {
|
||||
for key, value in record : key => value
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
resource "hetznerdns_record" "this" {
|
||||
|
||||
@@ -12,7 +12,7 @@ variable "records" {
|
||||
name = string
|
||||
value = string
|
||||
type = string
|
||||
ttl = optional(number, 3600)
|
||||
ttl = optional(number, null)
|
||||
}))
|
||||
default = []
|
||||
}
|
||||
|
||||
12
variables.tf
12
variables.tf
@@ -2,12 +2,12 @@ variable "hetzner_apitoken" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "google_dkim" {
|
||||
type = map(string)
|
||||
variable "nehrke_info_dkim" {
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "gmail_dns_default_ttl" {
|
||||
type = number
|
||||
default = 3600
|
||||
variable "sozpaedil_net_dkim" {
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user