File tree 4 files changed +62
-1
lines changed
4 files changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,6 @@ create_dns_record = true
6
6
dns_record_subdomain_including_dot = " dev."
7
7
8
8
create_redirect_from_www_domain = false
9
- dns_record_www_domain_including_dot = " www.dev."
9
+ dns_record_www_domain_including_dot = " www.dev."
10
+
11
+ prevent_email_spoofing = false
Original file line number Diff line number Diff line change
1
+
2
+ locals {
3
+ dns_zones_to_protect_against_email_spoofing = (
4
+ var. prevent_email_spoofing ?
5
+ tomap ({
6
+ zone_1 = data.aws_route53_zone.route_53_zone_for_our_domain,
7
+ })
8
+ : tomap ({})
9
+ )
10
+ }
11
+
12
+ resource "aws_route53_record" "dns_record_to_protect_against_email_spoofing__SPF" {
13
+ for_each = local. dns_zones_to_protect_against_email_spoofing
14
+
15
+ type = " TXT"
16
+ name = each. value . name // No subdomain
17
+ records = [" v=spf1 -all" ]
18
+ ttl = 60
19
+ zone_id = each. value . zone_id
20
+ }
21
+
22
+ resource "aws_route53_record" "dns_record_to_protect_against_email_spoofing__DMARC" {
23
+ for_each = local. dns_zones_to_protect_against_email_spoofing
24
+
25
+ type = " TXT"
26
+ name = " _dmarc.${ each . value . name } "
27
+ records = [
" v=DMARC1;p=reject;sp=reject;adkim=s;aspf=s;fo=1;rua=mailto:[email protected] " ]
28
+ ttl = 60
29
+ zone_id = each. value . zone_id
30
+ }
31
+
32
+ resource "aws_route53_record" "dns_record_to_protect_against_email_spoofing__DKIM" {
33
+ for_each = local. dns_zones_to_protect_against_email_spoofing
34
+
35
+ type = " TXT"
36
+ name = " *._domainkey.${ each . value . name } "
37
+ records = [" v=DKIM1; p=" ]
38
+ ttl = 60
39
+ zone_id = each. value . zone_id
40
+ }
41
+
42
+ resource "aws_route53_record" "dns_record_to_protect_against_email_spoofing__MX" {
43
+ for_each = local. dns_zones_to_protect_against_email_spoofing
44
+
45
+ type = " MX"
46
+ name = each. value . name // No subdomain
47
+ records = [" 0 ." ]
48
+ ttl = 60
49
+ zone_id = each. value . zone_id
50
+ }
Original file line number Diff line number Diff line change @@ -7,3 +7,5 @@ dns_record_subdomain_including_dot = ""
7
7
8
8
create_redirect_from_www_domain = true
9
9
dns_record_www_domain_including_dot = " www."
10
+
11
+ prevent_email_spoofing = true
Original file line number Diff line number Diff line change @@ -42,6 +42,13 @@ variable "dns_record_www_domain_including_dot" {
42
42
description = " The www. domain (including dot - e.g. 'www.dev.' or just 'www.' for production) for the www domain redirect"
43
43
}
44
44
45
+ variable "prevent_email_spoofing" {
46
+ type = bool
47
+ description = " Should terraform create DNS records to prevent email spoofing (only required for the prod environment)"
48
+ default = false
49
+ }
50
+
51
+
45
52
// SECRETS
46
53
// These variables are set in GitHub Actions environment-specific secrets
47
54
// Most of these are passed to the application via Elastic Beanstalk environment variables
You can’t perform that action at this time.
0 commit comments