Skip to content

Commit

Permalink
Update ses addon module to have better SPF records (#21879)
Browse files Browse the repository at this point in the history
This helps prevent invite emails from Fleet going to spam instead of
someone's inbox.
  • Loading branch information
rfairburn committed Sep 9, 2024
1 parent e57876a commit 4fb0fd5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions terraform/addons/ses/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
locals {
spf_domains = [
aws_ses_domain_identity.default.domain,
"_amazonses.${aws_ses_domain_identity.default.domain}"
]
}

resource "aws_ses_domain_identity" "default" {
domain = var.domain
}
Expand All @@ -19,11 +26,12 @@ resource "aws_route53_record" "amazonses_dkim_record" {


resource "aws_route53_record" "spf_domain" {
zone_id = var.zone_id
name = "_amazonses.${aws_ses_domain_identity.default.domain}"
type = "TXT"
ttl = "600"
records = ["v=spf1 include:amazonses.com -all"]
for_each = toset(local.spf_domains)
zone_id = var.zone_id
name = each.key
type = "TXT"
ttl = "600"
records = ["v=spf1 include:amazonses.com -all"]
}

resource "aws_iam_policy" "main" {
Expand Down
2 changes: 1 addition & 1 deletion terraform/addons/ses/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ variable "domain" {
}

variable "zone_id" {
type = string
type = string
description = "Route53 Zone ID"
}

0 comments on commit 4fb0fd5

Please sign in to comment.