Skip to content

Commit 2ec3fc3

Browse files
committed
Configure DMARC for SES
1 parent b85a6f8 commit 2ec3fc3

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

terraform/route53.tf

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,49 @@ resource "aws_route53_record" "ses-compiler-explorer-com" {
120120
records = [aws_ses_domain_identity.compiler-explorer-com.verification_token]
121121
}
122122

123+
resource "aws_ses_domain_mail_from" "compiler-explorer-com" {
124+
domain = aws_ses_domain_identity.compiler-explorer-com.domain
125+
mail_from_domain = "bounce.${aws_ses_domain_identity.compiler-explorer-com.domain}"
126+
behavior_on_mx_failure = "UseDefaultValue"
127+
}
128+
129+
resource "aws_route53_record" "ses-bounce-mx-compiler-explorer-com" {
130+
name = aws_ses_domain_mail_from.compiler-explorer-com.mail_from_domain
131+
zone_id = module.compiler-explorer-com.zone_id
132+
ttl = 3600
133+
type = "MX"
134+
records = ["10 feedback-smtp.us-east-1.amazonses.com"]
135+
}
136+
137+
resource "aws_route53_record" "ses-bounce-spf-compiler-explorer-com" {
138+
name = aws_ses_domain_mail_from.compiler-explorer-com.mail_from_domain
139+
zone_id = module.compiler-explorer-com.zone_id
140+
ttl = 3600
141+
type = "TXT"
142+
records = ["v=spf1 include:amazonses.com ~all"]
143+
}
144+
145+
resource "aws_ses_domain_dkim" "compiler-explorer-com" {
146+
domain = aws_ses_domain_identity.compiler-explorer-com.domain
147+
}
148+
149+
resource "aws_route53_record" "ses-dkim-compiler-explorer-com" {
150+
count = 3
151+
name = "${aws_ses_domain_dkim.compiler-explorer-com.dkim_tokens[count.index]}._domainkey"
152+
zone_id = module.compiler-explorer-com.zone_id
153+
ttl = 3600
154+
type = "CNAME"
155+
records = ["${aws_ses_domain_dkim.compiler-explorer-com.dkim_tokens[count.index]}.dkim.amazonses.com"]
156+
}
157+
158+
resource "aws_route53_record" "dmarc-compiler-explorer-com" {
159+
name = "_dmarc"
160+
zone_id = module.compiler-explorer-com.zone_id
161+
ttl = 3600
162+
type = "TXT"
163+
records = ["v=DMARC1; p=quarantine; rua=mailto:[email protected]"]
164+
}
165+
123166
resource "aws_route53_record" "api-compiler-explorer-com" {
124167
name = aws_apigatewayv2_domain_name.api-compiler-explorer-custom-domain.domain_name
125168
type = "A"

0 commit comments

Comments
 (0)