diff --git a/terraform/domains.tf b/terraform/domains.tf new file mode 100644 index 0000000..8840a64 --- /dev/null +++ b/terraform/domains.tf @@ -0,0 +1,143 @@ +locals { + domain_period = "1Y" + domain_renewal = "AUTORENEW" +} + +resource "inwx_domain_contact" "admin" { + // contact configuration + type = "PERSON" + name = var.admin_name + street_address = var.admin_street + city = var.admin_city + postal_code = var.admin_postal_code + country_code = var.admin_country_code + phone_number = var.admin_phone_number + email = var.admin_email + whois_protection = true +} + +resource "inwx_domain" "twomartens_de" { + name = "2martens.de" + nameservers = [ + "ns.inwx.de", + "ns2.inwx.de", + "ns3.inwx.eu" + ] + period = local.domain_period + renewal_mode = local.domain_renewal + transfer_lock = true + contacts { + // references to terraform managed contact "example_person" + registrant = inwx_domain_contact.admin.id + admin = inwx_domain_contact.admin.id + tech = 1 + billing = 1 + } +} + +resource "inwx_domain" "twomartens_eu" { + name = "2martens.eu" + nameservers = [ + "ns.inwx.de", + "ns2.inwx.de", + "ns3.inwx.eu" + ] + period = local.domain_period + renewal_mode = local.domain_renewal + transfer_lock = true + contacts { + // references to terraform managed contact "example_person" + registrant = inwx_domain_contact.admin.id + admin = inwx_domain_contact.admin.id + tech = 1 + billing = 1 + } + extra_data = { + "EU-COUNTRY-OF-CITIZENSHIP" : "DE" + } +} + +// NS records +resource "inwx_nameserver_record" "twomartens_de_ns1" { + domain = "2martens.de" + name = "" + content = "ns.inwx.de" + type = "NS" + ttl = 86400 +} + +resource "inwx_nameserver_record" "twomartens_de_ns2" { + domain = "2martens.de" + name = "" + content = "ns2.inwx.de" + type = "NS" + ttl = 86400 +} + +resource "inwx_nameserver_record" "twomartens_de_ns3" { + domain = "2martens.de" + name = "" + content = "ns3.inwx.eu" + type = "NS" + ttl = 86400 +} + +resource "inwx_nameserver_record" "twomartens_eu_ns1" { + domain = "2martens.eu" + name = "" + content = "ns.inwx.de" + type = "NS" + ttl = 86400 +} + +resource "inwx_nameserver_record" "twomartens_eu_ns2" { + domain = "2martens.eu" + name = "" + content = "ns2.inwx.de" + type = "NS" + ttl = 86400 +} + +resource "inwx_nameserver_record" "twomartens_eu_ns3" { + domain = "2martens.eu" + name = "" + content = "ns3.inwx.eu" + type = "NS" + ttl = 86400 +} + +// SOAs + +resource "inwx_nameserver_record" "twomartens_de_soa" { + domain = "2martens.de" + name = "" + content = "ns.inwx.de hostmaster.inwx.de 2023103000 10800 3600 604800 3600" + type = "SOA" + ttl = 86400 +} + +resource "inwx_nameserver_record" "twomartens_eu_soa" { + domain = "2martens.eu" + name = "" + content = "ns.inwx.de hostmaster.inwx.de 2020080805 10800 3600 604800 3600" + type = "SOA" + ttl = 86400 +} + +// redirect 2martens.eu to 2martens.de +resource "inwx_nameserver_record" "twomartens_eu_root_redirect" { + domain = "2martens.eu" + name = "" + content = "https://2martens.de" + type = "URL" + prio = 301 + ttl = 3600 +} +resource "inwx_nameserver_record" "twomartens_eu_www_redirect" { + domain = "2martens.eu" + name = "www" + content = "https://2martens.de" + type = "URL" + prio = 301 + ttl = 3600 +} \ No newline at end of file diff --git a/terraform/hetzner.tf b/terraform/hetzner.tf new file mode 100644 index 0000000..a545a7a --- /dev/null +++ b/terraform/hetzner.tf @@ -0,0 +1,14 @@ +module "drone_domain" { + source = "modules/domain" + domain = "2martens.de" + subdomain = "ci" + ipv4 = "49.12.69.146" + ipv6 = "2a01:4f8:c012:1fef::1" +} +resource "inwx_nameserver_record" "twomartens_de_ci-ownercheck_txt" { + domain = "2martens.de" + name = "ownercheck.ci" + content = "e1eb600b" + type = "TXT" + ttl = 3600 +} \ No newline at end of file diff --git a/terraform/ingress-apps.tf b/terraform/ingress-apps.tf new file mode 100644 index 0000000..7ab4531 --- /dev/null +++ b/terraform/ingress-apps.tf @@ -0,0 +1,15 @@ +module "argocd_domain" { + source = "modules/domain" + domain = "2martens.de" + subdomain = "argocd" + ipv4 = "49.13.77.70" + ipv6 = "2a01:4f8:c012:4d25::1" +} + +module "api_domain" { + source = "modules/domain" + domain = "2martens.de" + subdomain = "api" + ipv4 = "49.13.77.70" + ipv6 = "2a01:4f8:c012:4d25::1" +} \ No newline at end of file diff --git a/terraform/inwx.tf b/terraform/inwx.tf deleted file mode 100644 index 3a21a3c..0000000 --- a/terraform/inwx.tf +++ /dev/null @@ -1,74 +0,0 @@ -terraform { - required_providers { - inwx = { - source = "inwx/inwx" - version = "1.3.2" - } - } -} - -provider "inwx" { - api_url = "https://api.domrobot.com/jsonrpc/" - username = var.inwx_user - password = var.inwx_password - # Configuration options -} - -locals { - domain_period = "1Y" - domain_renewal = "AUTORENEW" -} - -resource "inwx_domain_contact" "admin" { - // contact configuration - type = "PERSON" - name = var.admin_name - street_address = var.admin_street - city = var.admin_city - postal_code = var.admin_postal_code - country_code = var.admin_country_code - phone_number = var.admin_phone_number - email = var.admin_email - whois_protection = true -} - -resource "inwx_domain" "twomartens_de" { - name = "2martens.de" - nameservers = [ - "ns.inwx.de", - "ns2.inwx.de", - "ns3.inwx.eu" - ] - period = local.domain_period - renewal_mode = local.domain_renewal - transfer_lock = true - contacts { - // references to terraform managed contact "example_person" - registrant = inwx_domain_contact.admin.id - admin = inwx_domain_contact.admin.id - tech = 1 - billing = 1 - } -} - -resource "inwx_domain" "twomartens_eu" { - name = "2martens.eu" - nameservers = [ - "ns.inwx.de", - "ns2.inwx.de", - "ns3.inwx.eu" - ] - period = local.domain_period - renewal_mode = local.domain_renewal - transfer_lock = true - contacts { - // references to terraform managed contact "example_person" - registrant = inwx_domain_contact.admin.id - admin = inwx_domain_contact.admin.id - tech = 1 - billing = 1 - } - extra_data = { - "EU-COUNTRY-OF-CITIZENSHIP": "DE" - } -} \ No newline at end of file diff --git a/terraform/main.tf b/terraform/main.tf index 7d3144e..78c84ed 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -6,4 +6,10 @@ terraform { name = "cloud-configuration" } } + required_providers { + inwx = { + source = "inwx/inwx" + version = "1.3.2" + } + } } \ No newline at end of file diff --git a/terraform/modules/domain/main.tf b/terraform/modules/domain/main.tf new file mode 100644 index 0000000..3b6c0a8 --- /dev/null +++ b/terraform/modules/domain/main.tf @@ -0,0 +1,31 @@ +resource "inwx_nameserver_record" "a" { + domain = var.domain + name = var.subdomain + content = var.ipv4 + type = "A" + ttl = 3600 +} +resource "inwx_nameserver_record" "aaaa" { + domain = var.domain + name = var.subdomain + content = var.ipv6 + type = "AAAA" + ttl = 3600 +} +resource "inwx_nameserver_record" "mx" { + domain = var.domain + name = var.subdomain + content = var.hostName + type = "MX" + prio = var.mxPrio + ttl = 3600 + count = var.hasMXRecord ? 1 : 0 +} +resource "inwx_nameserver_record" "mx-spf" { + domain = var.domain + name = var.subdomain + content = var.mxSpf + type = "TXT" + ttl = 3600 + count = var.hasMXRecord ? 1 : 0 +} \ No newline at end of file diff --git a/terraform/modules/domain/outputs.tf b/terraform/modules/domain/outputs.tf new file mode 100644 index 0000000..e69de29 diff --git a/terraform/modules/domain/variables.tf b/terraform/modules/domain/variables.tf new file mode 100644 index 0000000..e2bf774 --- /dev/null +++ b/terraform/modules/domain/variables.tf @@ -0,0 +1,35 @@ +variable "ipv4" { + type = string +} + +variable "ipv6" { + type = string +} + +variable "domain" { + type = string +} + +variable "subdomain" { + type = string +} + +variable "hasMXRecord" { + type = bool + default = false +} + +variable "hostName" { + type = string + default = "" +} + +variable "mxPrio" { + type = number + default = 0 +} + +variable "mxSpf" { + type = string + default = "" +} \ No newline at end of file diff --git a/terraform/nameserver_records.tf b/terraform/nameserver_records.tf new file mode 100644 index 0000000..e146e4d --- /dev/null +++ b/terraform/nameserver_records.tf @@ -0,0 +1,116 @@ +// A records +resource "inwx_nameserver_record" "twomartens_de_allris_a" { + domain = "2martens.de" + name = "allris" + content = "185.26.156.105" + type = "A" + ttl = 3600 +} + +resource "inwx_nameserver_record" "twomartens_de_autoconfig_a" { + domain = "2martens.de" + name = "autoconfig" + content = "185.26.156.22" + type = "A" + ttl = 3600 +} + +resource "inwx_nameserver_record" "twomartens_de_autodiscover_a" { + domain = "2martens.de" + name = "autodiscover" + content = "185.26.156.22" + type = "A" + ttl = 3600 +} + +resource "inwx_nameserver_record" "twomartens_de_jim_a" { + domain = "2martens.de" + name = "jim" + content = "185.26.156.65" + type = "A" + ttl = 3600 +} + +resource "inwx_nameserver_record" "twomartens_de_pad_a" { + domain = "2martens.de" + name = "pad" + content = "185.26.156.132" + type = "A" + ttl = 3600 +} + +resource "inwx_nameserver_record" "twomartens_de_short_a" { + domain = "2martens.de" + name = "short" + content = "95.143.172.56" + type = "A" + ttl = 3600 +} + +// AAAA records + +resource "inwx_nameserver_record" "twomartens_de_allris_aaaa" { + domain = "2martens.de" + name = "allris" + content = "2a00:d0c0:200:0:b9:1a:9c:61" + type = "AAAA" + ttl = 3600 +} + +resource "inwx_nameserver_record" "twomartens_de_autoconfig_aaaa" { + domain = "2martens.de" + name = "autoconfig" + content = "2a00:d0c0:200:0:b9:1a:9c16:5d" + type = "AAAA" + ttl = 3600 +} + +resource "inwx_nameserver_record" "twomartens_de_autodiscover_aaaa" { + domain = "2martens.de" + name = "autodiscover" + content = "2a00:d0c0:200:0:b9:1a:9c16:5d" + type = "AAAA" + ttl = 3600 +} + +resource "inwx_nameserver_record" "twomartens_de_jim_aaaa" { + domain = "2martens.de" + name = "jim" + content = "2a00:d0c0:200:0:b9:1a:9c:40" + type = "AAAA" + ttl = 3600 +} + +resource "inwx_nameserver_record" "twomartens_de_pad_aaaa" { + domain = "2martens.de" + name = "pad" + content = "2a00:d0c0:200:0:c0bf:e0ff:fec1:af72" + type = "AAAA" + ttl = 3600 +} + +resource "inwx_nameserver_record" "twomartens_de_short_aaaa" { + domain = "2martens.de" + name = "short" + content = "2001:1a50:11:0:3854:d4ff:fe62:e0d8" + type = "AAAA" + ttl = 3600 +} + +// CNAME records + +resource "inwx_nameserver_record" "twomartens_de_cdn_cname" { + domain = "2martens.de" + name = "cdn" + content = "d1fvxyvcoii67h.cloudfront.net" + type = "CNAME" + ttl = 3600 +} + +resource "inwx_nameserver_record" "twomartens_de_aws-validations-cdn_cname" { + domain = "2martens.de" + name = "_4741e2d9c8a605950eebfa048029e4ef.cdn" + content = "_cf71e85bb40cc12717f2718e4590ad23.acm-validations.aws" + type = "CNAME" + ttl = 3600 +} diff --git a/terraform/providers.tf b/terraform/providers.tf new file mode 100644 index 0000000..bc09c10 --- /dev/null +++ b/terraform/providers.tf @@ -0,0 +1,6 @@ +provider "inwx" { + api_url = "https://api.domrobot.com/jsonrpc/" + username = var.inwx_user + password = var.inwx_password + # Configuration options +} \ No newline at end of file diff --git a/terraform/uberspace.tf b/terraform/uberspace.tf new file mode 100644 index 0000000..309a73a --- /dev/null +++ b/terraform/uberspace.tf @@ -0,0 +1,89 @@ +// Identity management +module "keycloak_domain" { + source = "modules/domain" + domain = "2martens.de" + subdomain = "id" + ipv4 = "95.143.172.184" + ipv6 = "2001:1a50:11:0:98b3:92ff:fe3e:bba1" + hasMXRecord = true + hostName = "monoceres.uberspace.de" + mxPrio = 0 + mxSpf = "v=spf1 include:spf.uberspace.de ~all" +} + +// Angular frontends +module "wahlrecht_domain" { + source = "modules/domain" + domain = "2martens.de" + subdomain = "wahlrecht" + ipv4 = "185.26.156.43" + ipv6 = "2a00:d0c0:200:0:470:9fff:fe83:16bc" +} + +// CI/CD +module "gitea_domain" { + source = "modules/domain" + domain = "2martens.de" + subdomain = "git" + ipv4 = "185.26.156.91" + ipv6 = "2a00:d0c0:200:0:b9:1a:9c:5a" +} + +module "helm-repo_domain" { + source = "modules/domain" + domain = "2martens.de" + subdomain = "repo" + ipv4 = "185.26.156.49" + ipv6 = "2a00:d0c0:200:0:2ca6:bff:fe78:832f" +} + +// Monitoring +module "statping_domain" { + source = "modules/domain" + domain = "2martens.de" + subdomain = "status" + ipv4 = "185.26.156.33" + ipv6 = "2a00:d0c0:200:0:f8e2:6fff:fec2:7a92" +} + +// Personal Website +module "personal_website_domain" { + source = "modules/domain" + domain = "2martens.de" + subdomain = "" + ipv4 = "185.26.156.65" + ipv6 = "2a00:d0c0:200:0:b9:1a:9c:40" + hasMXRecord = true + hostName = "howell.uberspace.de" + mxPrio = 10 + mxSpf = "v=spf1 include:spf.uberspace.de" +} +resource "inwx_nameserver_record" "twomartens_de_google-verification_txt" { + domain = "2martens.de" + name = "" + content = "google-site-verification=nUFiHQFxBpBMdX96ELH3TcfyIfXf2ZlwMFYtXjVq5lo" + type = "TXT" + ttl = 3600 +} + +// Nextcloud +module "nextcloud_domain" { + source = "modules/domain" + domain = "2martens.de" + subdomain = "cloud" + ipv4 = "185.26.156.194" + ipv6 = "2a00:d0c0:200:0:b9:1a:9c:95" + hasMXRecord = true + hostName = "kushida.uberspace.de" + mxPrio = 0 + mxSpf = "v=spf1 mx ~all" +} + +// domain key +resource "inwx_nameserver_record" "twomartens_de_uberspace-domainkey_txt" { + domain = "2martens.de" + name = "uberspace._domainkey.id" + content = "v=DKIM1;t=s;n=core;p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqs3bFL8W77z7VJHCFbsJ3o68Y1uBbVsbIS1y35CMfRv6wp7si7aIG2ZeKqzdh2dTMsvtvSMaYVq1gT/EtRmTbU/BYC21ff8sqcVqn/ll5nNsk5jKWXTYAlTQp4LBQN7icw94ZNGr5/SDYcnv2nsBYFf2GUviObWXGHX4RaBFNj9NVUNWNin/HicvW+LsbfYq37QtlhjmUn9K96VCwKcTV1mx+Ek0osErYefcOVNawqWIlVRQDLkHZhk1StLsOpRqV+qEjhzTk4n4ZiNtLJG1D9CpHl24d5DKsQDyVFdEfqHimFTSNgiitlkuXg+i+NMiRA9G3gNJtvw8uvfN8f+stQIDAQAB" + type = "TXT" + ttl = 3600 +} \ No newline at end of file diff --git a/terraform/variables.tf b/terraform/variables.tf index 370590d..5e069a1 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -1,17 +1,17 @@ variable "inwx_user" { - type = string + type = string sensitive = true } variable "inwx_password" { - type = string + type = string sensitive = true } variable "admin_name" { - type = string + type = string sensitive = true } variable "admin_street" { - type = string + type = string sensitive = true } variable "admin_city" { @@ -24,10 +24,10 @@ variable "admin_country_code" { type = string } variable "admin_phone_number" { - type = string + type = string sensitive = true } variable "admin_email" { - type = string + type = string sensitive = true }