-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Walter Derezinski
committed
Mar 5, 2020
1 parent
ab47ff0
commit 04b4bc9
Showing
6 changed files
with
171 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
# terraform-aws-route53-fastmail | ||
Setups a route53 zone for fastmail with needed MX, SPF, and TXT resources. | ||
# Terraform AWS Route53 Fastmail module | ||
|
||
Add the needed DNS records to an AWS Route53 zone. The following items are added. | ||
|
||
- MX records for in1-smtp.messagingengine.com and in2-smtp.messagingengine.com. | ||
- SPF records | ||
- The _domainkey record for fastmail to validate the domain | ||
- CALDAV auto discovery record | ||
- CARDDAV auto discovery record | ||
- IMAPS auto discovery record | ||
- SUBMISSION auto discovery record | ||
- Configure web access with default mail.<domain> | ||
- Optional configuration for mailchimp to send mail as your domain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
locals { | ||
zone_id = var.zone_id | ||
ttl = var.ttl | ||
extra_spf = var.enable_mailchimp ? "include:servers.mcsv.net ${var.extra_spf}" : var.extra_spf | ||
web_hostname = var.web_hostname | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
|
||
data aws_route53_zone zone { | ||
zone_id = local.zone_id | ||
} | ||
|
||
resource aws_route53_record mx-0 { | ||
zone_id = data.aws_route53_zone.zone.zone_id | ||
name = data.aws_route53_zone.zone.name | ||
type = "MX" | ||
ttl = local.ttl | ||
|
||
records = [ | ||
"10 in1-smtp.messagingengine.com.", | ||
"20 in2-smtp.messagingengine.com" | ||
] | ||
} | ||
|
||
resource aws_route53_record mx-1 { | ||
zone_id = data.aws_route53_zone.zone.zone_id | ||
name = "*.${data.aws_route53_zone.zone.name}" | ||
type = "MX" | ||
ttl = local.ttl | ||
|
||
records = [ | ||
"10 in1-smtp.messagingengine.com.", | ||
"20 in2-smtp.messagingengine.com" | ||
] | ||
} | ||
|
||
resource aws_route53_record spf { | ||
zone_id = data.aws_route53_zone.zone.zone_id | ||
name = data.aws_route53_zone.zone.name | ||
type = "SPF" | ||
ttl = local.ttl | ||
|
||
records = [ | ||
"v=spf1 include:spf.messagingengine.com ${local.extra_spf} ?all" | ||
] | ||
} | ||
|
||
resource aws_route53_record txt { | ||
zone_id = data.aws_route53_zone.zone.zone_id | ||
name = data.aws_route53_zone.zone.name | ||
type = "TXT" | ||
ttl = local.ttl | ||
|
||
records = [ | ||
"v=spf1 include:spf.messagingengine.com ${local.extra_spf} ?all" | ||
] | ||
} | ||
|
||
resource aws_route53_record domainkey { | ||
count = 3 | ||
zone_id = data.aws_route53_zone.zone.zone_id | ||
name = "fm${count.index}._domainkey.${data.aws_route53_zone.zone.name}" | ||
type = "CNAME" | ||
ttl = local.ttl | ||
|
||
records = [ | ||
"fm${count.index}.${data.aws_route53_zone.zone.name}fmhosted.com." | ||
] | ||
} | ||
|
||
resource aws_route53_record caldav { | ||
zone_id = data.aws_route53_zone.zone.zone_id | ||
name = "_caldavs_.tcp.${data.aws_route53_zone.zone.name}" | ||
type = "SRV" | ||
ttl = local.ttl | ||
|
||
records = [ | ||
"0 1 443 caldav.fastmail.com." | ||
] | ||
} | ||
|
||
resource aws_route53_record carddav { | ||
zone_id = data.aws_route53_zone.zone.zone_id | ||
name = "_carddav._tcp.${data.aws_route53_zone.zone.name}" | ||
type = "SRV" | ||
ttl = local.ttl | ||
|
||
records = [ | ||
"0 1 443 carddav.fastmail.com." | ||
] | ||
} | ||
|
||
resource aws_route53_record imaps { | ||
zone_id = data.aws_route53_zone.zone.zone_id | ||
name = "_imaps._tcp.${data.aws_route53_zone.zone.name}" | ||
type = "SRV" | ||
ttl = local.ttl | ||
|
||
records = [ | ||
"0 1 993 imap.fastmail.com." | ||
] | ||
} | ||
|
||
resource aws_route53_record submission { | ||
zone_id = data.aws_route53_zone.zone.zone_id | ||
name = "_submission._tcp.${data.aws_route53_zone.zone.name}" | ||
type = "SRV" | ||
ttl = local.ttl | ||
|
||
records = [ | ||
"0 1 587 smtp.fastmail.com." | ||
] | ||
} | ||
|
||
resource aws_route53_record mail { | ||
zone_id = data.aws_route53_zone.zone.zone_id | ||
name = "${local.web_hostname}.${data.aws_route53_zone.zone.name}" | ||
type = "A" | ||
ttl = local.ttl | ||
|
||
records = [ | ||
"66.111.4.147", | ||
"66.111.4.148" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
terraform { | ||
required_version = "> 0.12.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
variable extra_spf { | ||
type = string | ||
default = "" | ||
description = "If you need to add extra configuration information to the SPF record." | ||
} | ||
|
||
variable ttl { | ||
type = number | ||
default = 3600 | ||
description = "The DNS TTL for all records." | ||
} | ||
|
||
variable enable_mailchimp { | ||
type = bool | ||
default = false | ||
description = "Add the required for SPF and TXT records for mail to be sent from mailchimp." | ||
} | ||
|
||
variable web_hostname { | ||
type = "string" | ||
default = "mail" | ||
description = "The hostname to use for web access." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
variable zone_id { | ||
type = string | ||
description = "The route53 zone id" | ||
} | ||
|