clan-infra/terraform/web01/dns.tf

72 lines
1.8 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",
2024-04-30 11:14:46 +00:00
"metrics",
"buildbot"
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
2024-06-10 10:00:10 +00:00
name = "mail._domainkey"
2023-07-13 16:37:14 +00:00
type = "TXT"
# take from `systemctl status opendkim`
2024-06-10 10:00:10 +00:00
value = "\"v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCdw2gyAg5TW2/OO2u8sbzlI6vfLkPycr4ufpfFQVvpd31hb6ctvpWXlzVHUDi9KyaWRydB7cAmYvPuZ7KFi1XPzQ213vy0S0AEbnXOJsTyT5FR8cmiuHPhiWGSMrSlB/l78kG6xK6A1x2lWCm2r7z/dzkLyCgAqI79YaUTcYO0eQIDAQAB\""
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\""
}