clan-infra/terraform/web01/dns.tf

71 lines
1.7 KiB
Terraform
Raw Normal View History

2023-07-13 15:47:35 +00:00
locals {
2024-04-13 14:08:20 +00:00
hostnames = [
2023-07-13 16:37:14 +00:00
"@",
"git",
"mail",
"cache",
"matrix",
2024-04-12 14:11:21 +00:00
"www",
2024-04-13 14:08:20 +00:00
"docs",
"metrics"
2023-07-13 15:47:35 +00:00
]
2023-07-04 17:56:58 +00:00
}
2023-07-13 16:37:14 +00:00
resource "hetznerdns_zone" "server" {
name = var.dns_zone
2023-07-13 16:37:14 +00:00
ttl = 3600
}
2023-07-05 10:52:45 +00:00
2023-07-13 16:37:14 +00:00
resource "hetznerdns_record" "server_a" {
2024-04-13 14:08:20 +00:00
for_each = toset(local.hostnames)
2023-07-13 16:37:14 +00:00
zone_id = hetznerdns_zone.server.id
name = each.value
type = "A"
value = var.ipv4_address
2023-07-13 16:37:14 +00:00
}
resource "hetznerdns_record" "server_aaaa" {
2024-04-13 14:08:20 +00:00
for_each = toset(local.hostnames)
2023-07-13 16:37:14 +00:00
zone_id = hetznerdns_zone.server.id
name = each.value
type = "AAAA"
value = var.ipv6_address
2023-07-13 16:37:14 +00:00
}
2023-07-05 10:52:45 +00:00
# for sending emails
2023-07-13 16:37:14 +00:00
resource "hetznerdns_record" "spf" {
zone_id = hetznerdns_zone.server.id
name = "@"
type = "TXT"
value = "\"v=spf1 ip4:${var.ipv4_address} ip6:${var.ipv6_address} ~all\""
2023-07-13 16:37:14 +00:00
}
resource "hetznerdns_record" "dkim" {
zone_id = hetznerdns_zone.server.id
name = "v1._hostnamekey"
2023-07-13 16:37:14 +00:00
type = "TXT"
# take from `systemctl status opendkim`
value = "\"v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDpQeJirqh8VFGHRQBemqF5CeicC/5qHJn3vqKkVIOQNqkgp7IE+EZDg+MXoxMQZEJ0RbO0JpZZgYpOf3jf8o5w56WbE4dbpbi+9112R57k5w41R16Q0EUjf7MbrLJqcF6mtf+3bPklF9ngdcWhgN024YfhR9SlebCOapCVYqVt8QIDAQAB\""
2023-07-13 16:37:14 +00:00
}
resource "hetznerdns_record" "adsp" {
zone_id = hetznerdns_zone.server.id
name = "_adsp._hostnamekey"
2023-07-13 16:37:14 +00:00
type = "TXT"
value = "\"dkim=all;\""
2023-07-13 16:41:09 +00:00
}
resource "hetznerdns_record" "matrix" {
zone_id = hetznerdns_zone.server.id
name = "_matrix._tcp"
type = "SRV"
value = "0 5 443 matrix"
2023-07-13 16:37:14 +00:00
}
resource "hetznerdns_record" "dmarc" {
zone_id = hetznerdns_zone.server.id
name = "_dmarc"
type = "TXT"
value = "\"v=DMARC1; p=none; adkim=r; aspf=r; rua=mailto:joerc.dmarc@thalheim.io; ruf=mailto:joerg.dmarc@thalheim.io; pct=100\""
}