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" {} 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" { variable "protonmail-domainkey-id" {
type = string type = string
default = "dr2jx5mioyzdmwndxrlrsgzx3nne5vtshiheypfxy7llz4e2hwrcq" default = "dr2jx5mioyzdmwndxrlrsgzx3nne5vtshiheypfxy7llz4e2hwrcq"
} }
locals { variable "protonmail-verification-key" {
address = { type = string
cname = { default = "6568aab64dccc1e888741cf9874730f7fc884a00"
"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."
}
}
} }
resource "namecheap_domain_records" "top" { resource "namecheap_domain_records" "top" {
domain = "othoulrich.com" domain = trim(var.apex-domain,".")
mode = "OVERWRITE" mode = "OVERWRITE"
email_type = "MX" email_type = "MX"
record { record {
address = local.address.alias["@.0"]
hostname = "@" hostname = "@"
address = var.host-rproxy
type = "ALIAS" type = "ALIAS"
ttl = 300 ttl = 300
} }
record { record {
address = local.address.cname["www"]
hostname = "www" hostname = "www"
address = var.apex-domain
type = "CNAME" type = "CNAME"
} }
record { record {
address = local.address.cname["code"]
hostname = "code" hostname = "code"
address = var.apex-domain
type = "CNAME" type = "CNAME"
} }
record { record {
address = local.address.mx["@.0"]
hostname = "@" hostname = "@"
address = "mail.protonmail.ch."
type = "MX" type = "MX"
} }
record { record {
address = local.address.mx["@.1"]
hostname = "@" hostname = "@"
address = "mailsec.protonmail.ch."
mx_pref = 20 mx_pref = 20
type = "MX" type = "MX"
} }
record { record {
address = local.address.txt["@.0"]
hostname = "@" hostname = "@"
address = join("=",[
"protonmail-verification",
var.protonmail-verification-key
])
type = "TXT" type = "TXT"
} }
record { record {
address = local.address.txt["@.1"]
hostname = "@" hostname = "@"
address = "v=spf1 include:_spf.protonmail.ch mx ~all"
type = "TXT" type = "TXT"
} }
record { record {
address = local.address.cname["protonmail._domainkey"]
hostname = "protonmail._domainkey" hostname = "protonmail._domainkey"
address = join(".",[
"protonmail.domainkey",
var.protonmail-domainkey-id,
"domains.proton.ch."
])
type = "CNAME" type = "CNAME"
} }
record { record {
address = local.address.cname["protonmail2._domainkey"]
hostname = "protonmail2._domainkey" hostname = "protonmail2._domainkey"
address = join(".",[
"protonmail2.domainkey",
var.protonmail-domainkey-id,
"domains.proton.ch."
])
type = "CNAME" type = "CNAME"
} }
record { record {
address = local.address.cname["protonmail3._domainkey"]
hostname = "protonmail3._domainkey" hostname = "protonmail3._domainkey"
address = join(".",[
"protonmail3.domainkey",
var.protonmail-domainkey-id,
"domains.proton.ch."
])
type = "CNAME" type = "CNAME"
} }
} }