diff --git a/infra/email-server/route53-mail-shockrah-xyz.tf b/infra/email-server/route53-mail-shockrah-xyz.tf new file mode 100644 index 0000000..ff95a91 --- /dev/null +++ b/infra/email-server/route53-mail-shockrah-xyz.tf @@ -0,0 +1,40 @@ + # Mail stuff + locals { + records = [ + { name = "mail.shockrah.xyz", records = [ "45.76.78.158" ] }, + { name = "box.mail.shockrah.xyz", records = [ "45.76.78.158" ] }, + { name = "158.78.76.45.in-addr.arpa", type = "PTR", records = [ "box.mail.shockrah.xyz" ] }, + { name = "8.6.8.2.e.9.e.f.f.f.4.0.0.0.4.5.1.d.f.3.1.0.0.6.0.f.9.1.1.0.0.2.ip6.arpa", type = "PTR", records = [ "box.mail.shockrah.xyz" ] }, + # glue records + { name = "ns1.mail.shockrah.xyz", records = [ "45.76.78.158" ] }, + { name = "ns2.mail.shockrah.xyz", records = [ "45.76.78.158" ] }, + # ipv6 record + { name = "mail.shockrah.xyz", type = "AAAA", records = [ "2001:19f0:6001:3fd1:5400:04ff:fe9e:2868" ] }, + # For mail in a box safety checks + { name = "www.mail.shockrah.xyz", records = [ "45.76.78.158" ] }, + { name = "autoconfig.mail.shockrah.xyz", records = [ "45.76.78.158" ] }, + { name = "autodiscover.mail.shockrah.xyz", records = [ "45.76.78.158" ] }, + + { name = "www.mail.shockrah.xyz", type = "AAAA", records = [ "2001:19f0:6001:3fd1:5400:04ff:fe9e:2868" ] }, + { name = "autoconfig.mail.shockrah.xyz", type = "AAAA", records = [ "2001:19f0:6001:3fd1:5400:04ff:fe9e:2868" ] }, + { name = "autodiscover.mail.shockrah.xyz", type = "AAAA", records = [ "2001:19f0:6001:3fd1:5400:04ff:fe9e:2868" ] }, + { name = "box.mail.shockrah.xyz", type = "AAAA", records = [ "2001:19f0:6001:3fd1:5400:04ff:fe9e:2868" ] }, + { name = "mta-sts.mail.shockrah.xyz", type = "AAAA", records = [ "2001:19f0:6001:3fd1:5400:04ff:fe9e:2868" ] }, + { name = "mta-sts.box.mail.shockrah.xyz", type = "AAAA", records = [ "2001:19f0:6001:3fd1:5400:04ff:fe9e:2868" ] }, + { name = "mta-sts.mail.shockrah.xyz", records = [ "45.76.78.158" ] }, + { name = "mta-sts.box.mail.shockrah.xyz", records = [ "45.76.78.158" ] }, + ] +} + +resource "aws_route53_record" "mail" { + for_each = { + for index, record in local.records: + index => record + } + + zone_id = aws_route53_zone.shockrah-xyz.id + name = each.value.name + type = lookup(each.value, "type", "A") + ttl = lookup(each.value, "ttl", 300) + records = each.value.records +} diff --git a/infra/email-server/variables.tf b/infra/email-server/variables.tf index b216c51..dfe94a2 100644 --- a/infra/email-server/variables.tf +++ b/infra/email-server/variables.tf @@ -30,3 +30,7 @@ variable mail { }) } +variable route53_zone_id { + type = string + sensitive = true +}