Improved terraform formatting and update ALIAS.

This commit is contained in:
Otho Ulrich 2023-01-01 00:26:38 -05:00
parent dd10afba67
commit f8fdea2975
Signed by: Otho
GPG Key ID: 16C720CD3BBE21D9

87
dns.tf
View File

@ -18,115 +18,106 @@ terraform {
provider "namecheap" {}
variable "apex-domain" {
type = string
default = "othoulrich.com."
}
variable "host-rproxy" {
type = string
default = "rprxy-0.saline.o4data.net."
}
variable "protonmail-domainkey-id" {
type = string
default = "dr2jx5mioyzdmwndxrlrsgzx3nne5vtshiheypfxy7llz4e2hwrcq"
}
locals {
address = {
cname = {
"www" = "othoulrich.com."
"code" = "othoulrich.com."
"protonmail._domainkey" = join(".",[
"protonmail.domainkey",
var.protonmail-domainkey-id,
"domains.proton.ch."
])
"protonmail2._domainkey" = join(".",[
"protonmail2.domainkey",
var.protonmail-domainkey-id,
"domains.proton.ch."
])
"protonmail3._domainkey" = join(".",[
"protonmail3.domainkey",
var.protonmail-domainkey-id,
"domains.proton.ch."
])
}
txt = {
"@.0" = join("=",[
"protonmail-verification",
"6568aab64dccc1e888741cf9874730f7fc884a00"
])
"@.1" = "v=spf1 include:_spf.protonmail.ch mx ~all"
}
mx = {
"@.0" = "mail.protonmail.ch."
"@.1" = "mailsec.protonmail.ch."
}
alias = {
"@.0" = "fw-0.saline.o4data.net."
}
}
variable "protonmail-verification-key" {
type = string
default = "6568aab64dccc1e888741cf9874730f7fc884a00"
}
resource "namecheap_domain_records" "top" {
domain = "othoulrich.com"
domain = trim(var.apex-domain,".")
mode = "OVERWRITE"
email_type = "MX"
record {
address = local.address.alias["@.0"]
hostname = "@"
address = var.host-rproxy
type = "ALIAS"
ttl = 300
}
record {
address = local.address.cname["www"]
hostname = "www"
address = var.apex-domain
type = "CNAME"
}
record {
address = local.address.cname["code"]
hostname = "code"
address = var.apex-domain
type = "CNAME"
}
record {
address = local.address.mx["@.0"]
hostname = "@"
address = "mail.protonmail.ch."
type = "MX"
}
record {
address = local.address.mx["@.1"]
hostname = "@"
address = "mailsec.protonmail.ch."
mx_pref = 20
type = "MX"
}
record {
address = local.address.txt["@.0"]
hostname = "@"
address = join("=",[
"protonmail-verification",
var.protonmail-verification-key
])
type = "TXT"
}
record {
address = local.address.txt["@.1"]
hostname = "@"
address = "v=spf1 include:_spf.protonmail.ch mx ~all"
type = "TXT"
}
record {
address = local.address.cname["protonmail._domainkey"]
hostname = "protonmail._domainkey"
address = join(".",[
"protonmail.domainkey",
var.protonmail-domainkey-id,
"domains.proton.ch."
])
type = "CNAME"
}
record {
address = local.address.cname["protonmail2._domainkey"]
hostname = "protonmail2._domainkey"
address = join(".",[
"protonmail2.domainkey",
var.protonmail-domainkey-id,
"domains.proton.ch."
])
type = "CNAME"
}
record {
address = local.address.cname["protonmail3._domainkey"]
hostname = "protonmail3._domainkey"
address = join(".",[
"protonmail3.domainkey",
var.protonmail-domainkey-id,
"domains.proton.ch."
])
type = "CNAME"
}
}