-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.tf
58 lines (51 loc) · 1.31 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.40"
}
}
required_version = ">= 1.3"
}
# Null MX record specified in RFC 7505
# https://datatracker.ietf.org/doc/rfc7505/
resource "aws_route53_record" "mx_root" {
zone_id = var.zone_id
type = "MX"
name = ""
records = ["0 ."]
ttl = var.ttl
}
resource "aws_route53_record" "mx_subdomains" {
count = var.include_subdomains ? 1 : 0
zone_id = var.zone_id
type = "MX"
name = "*"
records = ["0 ."]
ttl = var.ttl
}
# Ensure all SPF validations to fail for the root domain.
resource "aws_route53_record" "spf_root" {
zone_id = var.zone_id
type = "TXT"
name = ""
records = ["v=spf1 -all"]
ttl = var.ttl
}
# Ensure all SPF validations to fail for subdomains.
resource "aws_route53_record" "spf_subdomains" {
count = var.include_subdomains ? 1 : 0
zone_id = var.zone_id
type = "TXT"
name = "*"
records = ["v=spf1 -all"]
ttl = var.ttl
}
# Advise receivers to reject emails when DMARC alignment fails.
resource "aws_route53_record" "dmarc" {
zone_id = var.zone_id
type = "TXT"
name = "_dmarc"
records = [var.aggregate_feedback_email != "" ? "v=DMARC1; p=reject; rua=${var.aggregate_feedback_email}" : "v=DMARC1; p=reject;"]
ttl = var.ttl
}