diff --git a/dns.tf b/dns.tf
new file mode 100644
index 0000000..2ef7fbb
--- /dev/null
+++ b/dns.tf
@@ -0,0 +1,104 @@
+resource "dnsimple_zone" "zones" {
+ for_each = {
+ alphachen_dev = "alphachen.dev"
+ arbitrary_definitions = "arbitrarydefinitions.com"
+ chislan_family = "chislan.family"
+ islan_me = "islan.me"
+ kejadlen_dev = "kejadlen.dev"
+ }
+
+ name = each.value
+ active = true
+}
+
+resource "dnsimple_zone_record" "subdomains" {
+ for_each = {
+ auth = { zone = dnsimple_zone.zones["chislan_family"], ip = local.lotus_land_story.ip_address }
+ docs = { zone = dnsimple_zone.zones["chislan_family"], ip = local.lotus_land_story.ip_address }
+ }
+
+ zone_name = each.value.zone.name
+ name = each.key
+ value = each.value.ip
+ type = "A"
+}
+
+# TODO
+# - mitmproxy?
+resource "dnsimple_zone_record" "kejadlen_dev_subdomains" {
+ for_each = {
+ auth = local.lotus_land_story.ip_address
+ git = local.lotus_land_story.ip_address
+ hey = local.lotus_land_story.ip_address
+ monica = local.ramble_hard.ip_address
+ social = local.ramble_hard.ip_address
+ }
+
+ zone_name = dnsimple_zone.zones["kejadlen_dev"].name
+ name = each.key
+ value = each.value
+ type = "A"
+}
+
+resource "dnsimple_zone_record" "kejadlen_dev_amazon_ses" {
+ for_each = {
+ dkim_0 = {
+ type = "CNAME"
+ name = "x76j3kgcyouqomw2q3iuxfrulgqmqdy3._domainkey"
+ value = "x76j3kgcyouqomw2q3iuxfrulgqmqdy3.skim.amazonses.com"
+ }
+ dkim_1 = {
+ type = "CNAME"
+ name = "ruslnm7oo3s3t2xofmbn6brinbzeacxj._domainkey"
+ value = "ruslnm7oo3s3t2xofmbn6brinbzeacxj.skim.amazonses.com"
+ }
+ dkim_2 = {
+ type = "CNAME"
+ name = "kew5ewv4jhf6a6x2t2tncmfts4os7vfy._domainkey"
+ value = "kew5ewv4jhf6a6x2t2tncmfts4os7vfy.skim.amazonses.com"
+ }
+ ses_mx = {
+ type = "MX"
+ name = "ses"
+ value = "feedback-smtp.us-west-2.amazonses.com"
+ priority = 10
+ }
+ ses_txt = {
+ type = "TXT"
+ name = "ses"
+ value = "v=spf1 include:amazonses.com ~all"
+ }
+ }
+
+ zone_name = dnsimple_zone.zones["kejadlen_dev"].name
+ type = each.value.type
+ name = each.value.name
+ value = each.value.value
+ priority = try(each.value.priority, null)
+}
+
+resource "dnsimple_zone_record" "kejadlen_dev_smtp2go" {
+ for_each = {
+ em539125 = "return.smtp2go.net"
+ "s539125._domainkey" = "dkim.smtp2go.net"
+ link = "track.smtp2go.net"
+ }
+
+ zone_name = dnsimple_zone.zones["kejadlen_dev"].name
+ name = each.key
+ value = each.value
+ type = "CNAME"
+}
+
+module "fastmail" {
+ for_each = {
+ alphachen_dev = dnsimple_zone.zones["alphachen_dev"]
+ arbitrary_definitions = dnsimple_zone.zones["arbitrary_definitions"]
+ chislan_family = dnsimple_zone.zones["chislan_family"]
+ islan_me = dnsimple_zone.zones["islan_me"]
+ kejadlen_dev = dnsimple_zone.zones["kejadlen_dev"]
+ }
+
+ source = "./modules/fastmail"
+ zone = each.value
+}
diff --git a/main.tf b/main.tf
index f370204..6a00300 100644
--- a/main.tf
+++ b/main.tf
@@ -9,7 +9,7 @@ terraform {
required_providers {
dnsimple = {
source = "dnsimple/dnsimple"
- version = "1.10.0"
+ version = "~> 1.10"
}
linode = {
diff --git a/dnsimple.tf b/modules/fastmail/main.tf
similarity index 69%
rename from dnsimple.tf
rename to modules/fastmail/main.tf
index e7e4720..e63261a 100644
--- a/dnsimple.tf
+++ b/modules/fastmail/main.tf
@@ -1,47 +1,55 @@
# https://www.fastmail.help/hc/en-us/articles/360060591153-Manual-DNS-configuration
-resource "dnsimple_zone" "islan_me" {
- name = "islan.me"
- active = true
-}
-
-resource "dnsimple_zone_record" "islan_me_mx" {
+# Standard Mail
+resource "dnsimple_zone_record" "mx" {
for_each = {
mx1 = { value = "in1-smtp.messagingengine.com", priority = 10 }
mx2 = { value = "in2-smtp.messagingengine.com", priority = 20 }
}
- zone_name = dnsimple_zone.islan_me.name
+ zone_name = var.zone.name
name = ""
value = each.value.value
type = "MX"
priority = each.value.priority
}
-resource "dnsimple_zone_record" "islan_me_spf" {
- zone_name = dnsimple_zone.islan_me.name
- name = ""
- value = "v=spf1 include:spf.messagingengine.com ?all"
- type = "TXT"
+# Webmail Login Portal
+resource "dnsimple_zone_record" "webmail" {
+ zone_name = var.zone.name
+ name = "mail"
+ value = "mail.fastmail.com"
+ type = "CNAME"
}
-resource "dnsimple_zone_record" "islan_me_dkim" {
+# DKIM
+resource "dnsimple_zone_record" "dkim" {
for_each = toset(["fm1", "fm2", "fm3"])
- zone_name = dnsimple_zone.islan_me.name
+ zone_name = var.zone.name
name = "${each.key}._domainkey"
- value = "${each.key}.islan.me.dkim.fmhosted.com"
+ value = "${each.key}.${var.zone.name}.dkim.fmhosted.com"
type = "CNAME"
}
-resource "dnsimple_zone_record" "islan_me_dmarc" {
- zone_name = dnsimple_zone.islan_me.name
+# SPF
+resource "dnsimple_zone_record" "spf" {
+ zone_name = var.zone.name
+ name = ""
+ value = "v=spf1 include:spf.messagingengine.com ?all"
+ type = "TXT"
+}
+
+# DMARC
+resource "dnsimple_zone_record" "dmarc" {
+ zone_name = var.zone.name
name = "_dmarc"
value = "v=DMARC1; p=none;"
type = "TXT"
}
-resource "dnsimple_zone_record" "islan_me_autodiscover" {
+# Client email auto-discovery
+resource "dnsimple_zone_record" "autodiscover" {
for_each = {
submission = { priority = 0, weight = 0, port = 0, target = "." }
submissions = { priority = 0, weight = 1, port = 465, target = "smtp.fastmail.com" }
@@ -53,7 +61,7 @@ resource "dnsimple_zone_record" "islan_me_autodiscover" {
autodiscover = { priority = 0, weight = 1, port = 443, target = "autodiscover.fastmail.com" }
}
- zone_name = dnsimple_zone.islan_me.name
+ zone_name = var.zone.name
name = "_${each.key}._tcp"
value = "${each.value.weight} ${each.value.port} ${each.value.target}"
priority = each.value.priority
diff --git a/modules/fastmail/variables.tf b/modules/fastmail/variables.tf
new file mode 100644
index 0000000..d57276c
--- /dev/null
+++ b/modules/fastmail/variables.tf
@@ -0,0 +1,6 @@
+variable "zone" {
+ description = "The DNS zone resource"
+ type = object({
+ name = string
+ })
+}
\ No newline at end of file
diff --git a/modules/fastmail/versions.tf b/modules/fastmail/versions.tf
new file mode 100644
index 0000000..77b2869
--- /dev/null
+++ b/modules/fastmail/versions.tf
@@ -0,0 +1,9 @@
+terraform {
+ required_providers {
+ dnsimple = {
+ source = "dnsimple/dnsimple"
+ version = "~> 1.10"
+ }
+ }
+}
+