fastmail terraform module

main
Alpha Chen 9 months ago
parent 990fe523b3
commit 7eb7115bf9
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -2,23 +2,23 @@
# Manual edits may be lost in future updates.
provider "registry.terraform.io/linode/linode" {
version = "1.29.4"
constraints = "1.29.4"
version = "2.18.0"
constraints = "2.18.0"
hashes = [
"h1:pdhSuNr3SQWvHHI+C1zF8J8tJetxGJoCQNxgsg1QHQs=",
"zh:06ccda35d968429a1184aaf981c8104394fa1d719de86b718c56d93c27c1fcd6",
"zh:1fb2497917094e77bde90fe6ee781e20cee739142b891391480c1b3376d81dbb",
"zh:27960e9c07e995aad07a9c5ebfd7fe0304fffd4cb159fd215e82932b798c6d55",
"zh:4ed29807c423c77aab1338972aa1ec3cc16c6b14f4c25c86f4427e8a86bfc467",
"zh:7a39103dc0dc8538f5258d3b64db1e6c91335640763bd05da0478e99748a4949",
"zh:95b3e418e6fcb4b826be9b289a834f1b9893977bd330ac418e0285e56a4644c1",
"zh:ac69c992a5cbaaa6ed9bb65206309ab2c71b5eb17740b7a5295532f9840c67fd",
"zh:ae943e8975075cd9664f00a028838566fdf879c772e518b7adcc82e757916a67",
"zh:b3a85a52489bc3777b5e8c4428b8ea42ae8e0f2398077699c1eb99acea931a34",
"zh:c1a2e945f5691ed97b9cf01351dd3a99c2f9871f172bd71ba0c8a810c75740cd",
"zh:ce86a03d73ee3d2ed58c6fe853cd2a9d0974710d94a0aeb4c195a9d1e78a3481",
"zh:d34afbbf848d8b541a068d64fa04ace13c3bd37ad19fd8b0796662f553ca9652",
"zh:e13b4847098d295cd8216eeec55d940cfc4544672fdc89e0048dd067e69b63f8",
"zh:fc62e9f8fc5d37d28aba2077db10355839cae6d7770eaf8711f97877bac046ab",
"h1:CeGbgARw4BrgUrEfPVRUjwoPI5WrCtA4bG39ckFHrlQ=",
"zh:03bc6644991818395759757cc5a3f07b6a8f7f797f04d701441e79e85cb9dc69",
"zh:5248ed1626e1531616fd227840c7734b8f2d13631427d80672b615e60f106a2d",
"zh:80a890b44a66639b1dabc2773e5dbb5f22a8e73495ce167a5064296463e17cdc",
"zh:874f5794a567250fc873af73c8c67a1980eb30de864ef76eb772ae492cf530ba",
"zh:94469b62cc27ce53fcd06a48b84de256136576699602ba68d157b2ad033ac0ed",
"zh:a1b9096702e1ee197f84634159d512b54d9223d00ff850ff4073eb9e5ac5eb9d",
"zh:a39c77dbf770a349529596124d4188fc7eeb8ecaf88ebc06f586d884f68df550",
"zh:bd5ee9da38d1846edc6af87771ede950bb703d99f78756c05da00fc0ca325be5",
"zh:c4b1d74d8d44ed258ca96a2b76d0101858672624a8d9731df8a97b8373dba728",
"zh:c69db2d6e4d7b04f9bc2f00223e61ae12127946043b07bca567fa3883bf5c071",
"zh:e818b9ea84e55ce1d2eb1f8852ec6606ce5d3691f356ea4eb3a701e5986ed339",
"zh:eeb7e6d518f62d6f02b497dbb5427a7a8ea38e2e5dddc8a114f7989a7a8c47f7",
"zh:fa77abf56e34701cdc49799cc13c6298be184d7cb48de20ee8b30e93fb3735a0",
"zh:fc3e94acd6fb2ad6b526169896fc6821298ba394a4d181c9b2448341e2e0eb54",
]
}

@ -0,0 +1,83 @@
# https://www.fastmail.help/hc/en-us/articles/1500000280261-Setting-up-your-domain-MX-only#domain-registration
#
terraform {
required_providers {
linode = {
source = "linode/linode"
version = "2.18.0"
}
}
}
variable "domain" {
type = object({
id = string,
domain = string,
})
nullable = false
}
resource "linode_domain_record" "fastmail_mx" {
domain_id = var.domain.id
for_each = {
"in1-smtp.messagingengine.com" = 10
"in2-smtp.messagingengine.com" = 20
}
record_type = "MX"
priority = each.value
target = each.key
}
resource "linode_domain_record" "fastmail_spf" {
domain_id = var.domain.id
name = var.domain.domain
record_type = "TXT"
target = "v=spf1 include:spf.messagingengine.com ?all"
}
resource "linode_domain_record" "fastmail_dkim" {
domain_id = var.domain.id
for_each = {
"mesmtp._domainkey" = "mesmtp.${var.domain.domain}.dkim.fmhosted.com"
"fm1._domainkey" = "fm1.${var.domain.domain}.dkim.fmhosted.com"
"fm2._domainkey" = "fm2.${var.domain.domain}.dkim.fmhosted.com"
"fm3._domainkey" = "fm3.${var.domain.domain}.dkim.fmhosted.com"
}
name = each.key
record_type = "CNAME"
target = each.value
}
resource "linode_domain_record" "fastmail_dmarc" {
domain_id = var.domain.id
name = "_dmarc.${var.domain.domain}"
record_type = "TXT"
target = "v=DMARC1; p=none;"
}
resource "linode_domain_record" "fastmail_srv" {
domain_id = var.domain.id
for_each = {
"submission" = { priority = 0, weight = 1, port = 587, target = "smtp.fastmail.com" }
"imap" = { priority = 0, weight = 0, port = 0, target = "." }
"imaps" = { priority = 0, weight = 1, port = 993, target = "imap.fastmail.com" }
"pop3" = { priority = 0, weight = 0, port = 0, target = "." }
"pop3s" = { priority = 10, weight = 1, port = 995, target = "pop.fastmail.com" }
"jmap" = { priority = 0, weight = 1, port = 443, target = "api.fastmail.com" }
}
service = each.key
record_type = "SRV"
priority = each.value.priority
protocol = "tcp"
weight = each.value.weight
port = each.value.port
target = each.value.target
}

@ -9,7 +9,7 @@ terraform {
required_providers {
linode = {
source = "linode/linode"
version = "1.29.4"
version = "2.18.0"
}
}
}
@ -38,8 +38,14 @@ locals {
lotus_land_story = data.linode_instances.lotus_land_story.instances.0
}
resource "linode_domain" "kejadlen-dev" {
resource "linode_domain" "kejadlen_dev" {
type = "master"
domain = "kejadlen.dev"
soa_email = var.soa_email
}
resource "linode_domain" "chislan_family" {
type = "master"
domain = "chislan.family"
soa_email = var.soa_email
}

Loading…
Cancel
Save