feat: Add AWS CDN DNS records

This commit is contained in:
2026-02-07 17:11:09 +01:00
parent 1ce0fb8a36
commit 96ac8fd918
7 changed files with 79 additions and 102 deletions
+4 -99
View File
@@ -1,104 +1,9 @@
import { import {
to = module.keycloak_domain.hcloud_zone_rrset.a[0] to = module.cdn_domain.hcloud_zone_rrset.cname
id = "2martens.de/id/A" id = "2martens.de/cdn/CNAME"
} }
import { import {
to = module.keycloak_domain.hcloud_zone_rrset.aaaa[0] to = module.cdn_domain.hcloud_zone_rrset.validation
id = "2martens.de/id/AAAA" id = "2martens.de/_4741e2d9c8a605950eebfa048029e4ef.cdn/CNAME"
}
import {
to = module.keycloak_domain.hcloud_zone_rrset.uberspace_domain_key[0]
id = "2martens.de/uberspace._domainkey.id/TXT"
}
import {
to = module.gitea_domain.hcloud_zone_rrset.a[0]
id = "2martens.de/git/A"
}
import {
to = module.gitea_domain.hcloud_zone_rrset.aaaa[0]
id = "2martens.de/git/AAAA"
}
import {
to = module.helm-repo_domain.hcloud_zone_rrset.a[0]
id = "2martens.de/repo/A"
}
import {
to = module.helm-repo_domain.hcloud_zone_rrset.aaaa[0]
id = "2martens.de/repo/AAAA"
}
import {
to = module.statping_domain.hcloud_zone_rrset.a[0]
id = "2martens.de/status/A"
}
import {
to = module.statping_domain.hcloud_zone_rrset.aaaa[0]
id = "2martens.de/status/AAAA"
}
import {
to = module.personal_website_domain.hcloud_zone_rrset.a[0]
id = "2martens.de/@/A"
}
import {
to = module.personal_website_domain.hcloud_zone_rrset.aaaa[0]
id = "2martens.de/@/AAAA"
}
import {
to = module.personal_website_domain.hcloud_zone_rrset.uberspace_domain_key[0]
id = "2martens.de/uberspace._domainkey/TXT"
}
import {
to = module.medium_domain.hcloud_zone_rrset.a[0]
id = "2martens.de/medium/A"
}
import {
to = module.medium_domain.hcloud_zone_rrset.aaaa[0]
id = "2martens.de/medium/AAAA"
}
import {
to = module.appreview_domain.hcloud_zone_rrset.mx[0]
id = "2martens.de/appreview/MX"
}
import {
to = module.appreview_domain.hcloud_zone_rrset.txt[0]
id = "2martens.de/appreview/TXT"
}
import {
to = module.appreview_domain.hcloud_zone_rrset.uberspace_domain_key[0]
id = "2martens.de/uberspace._domainkey.appreview/TXT"
}
import {
to = module.cms_domain.hcloud_zone_rrset.a[0]
id = "2martens.de/cms/A"
}
import {
to = module.cms_domain.hcloud_zone_rrset.aaaa[0]
id = "2martens.de/cms/AAAA"
}
import {
to = module.nas_domain.hcloud_zone_rrset.a[0]
id = "2martens.de/nas/A"
}
import {
to = module.nas_domain.hcloud_zone_rrset.aaaa[0]
id = "2martens.de/nas/AAAA"
} }
+25
View File
@@ -0,0 +1,25 @@
resource "hcloud_zone_rrset" "cname" {
zone = var.domain
name = var.subdomain != "" ? var.subdomain : "@"
type = "CNAME"
ttl = 3600
change_protection = true
records = [
{ value = var.cname_target }
]
}
resource "hcloud_zone_rrset" "validation" {
zone = var.domain
name = var.subdomain != "" ? format("%s.%s", var.validation_key, var.subdomain) : var.validation_key
type = "CNAME"
ttl = 3600
change_protection = true
records = [
{ value = var.validation_target }
]
}
+20
View File
@@ -0,0 +1,20 @@
variable "domain" {
type = string
}
variable "subdomain" {
type = string
default = ""
}
variable "cname_target" {
type = string
}
variable "validation_key" {
type = string
}
variable "validation_target" {
type = string
}
+8
View File
@@ -0,0 +1,8 @@
terraform {
required_providers {
hcloud = {
source = "hetznercloud/hcloud"
version = ">= 1.44.1"
}
}
}
+12 -2
View File
@@ -6,6 +6,8 @@ resource "hcloud_zone_rrset" "a" {
type = "A" type = "A"
ttl = 3600 ttl = 3600
change_protection = true
records = [ records = [
{ value = var.ipv4 } { value = var.ipv4 }
] ]
@@ -19,6 +21,8 @@ resource "hcloud_zone_rrset" "aaaa" {
type = "AAAA" type = "AAAA"
ttl = 3600 ttl = 3600
change_protection = true
records = [ records = [
{ value = var.ipv6 } { value = var.ipv6 }
] ]
@@ -32,6 +36,8 @@ resource "hcloud_zone_rrset" "mx" {
type = "MX" type = "MX"
ttl = 3600 ttl = 3600
change_protection = true
records = [ records = [
{ value = format("%s %s.", var.mxPrio, var.hostName) } { value = format("%s %s.", var.mxPrio, var.hostName) }
] ]
@@ -45,8 +51,10 @@ resource "hcloud_zone_rrset" "txt" {
type = "TXT" type = "TXT"
ttl = 3600 ttl = 3600
change_protection = true
records = [ records = [
for txtValue in var.txtValues: for txtValue in var.txtValues :
{ value = provider::hcloud::txt_record(txtValue) } { value = provider::hcloud::txt_record(txtValue) }
] ]
} }
@@ -59,7 +67,9 @@ resource "hcloud_zone_rrset" "uberspace_domain_key" {
type = "TXT" type = "TXT"
ttl = 3600 ttl = 3600
change_protection = true
records = [ records = [
{ value = provider::hcloud::txt_record(var.uberspaceDomainKey) } { value = provider::hcloud::txt_record(var.uberspaceDomainKey) }
] ]
} }
+10 -1
View File
@@ -21,4 +21,13 @@ module "nas_domain" {
subdomain = "nas" subdomain = "nas"
ipv4 = "31.19.63.181" ipv4 = "31.19.63.181"
ipv6 = "2a02:8108:c19:c400:9209:d0ff:fe70:7570" ipv6 = "2a02:8108:c19:c400:9209:d0ff:fe70:7570"
} }
module "cdn_domain" {
source = "./modules/aws_cdn"
domain = hcloud_zone.twomartens_de.name
subdomain = "cdn"
cname_target = "d1fvxyvcoii67h.cloudfront.net."
validation_key = "_4741e2d9c8a605950eebfa048029e4ef"
validation_target = "_cf71e85bb40cc12717f2718e4590ad23.acm-validations.aws."
}