-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
91 lines (78 loc) · 2.89 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
data "aws_route53_zone" "this" {
zone_id = var.zone_id
}
data "aws_region" "current" {}
resource "aws_ses_domain_identity" "this" {
domain = data.aws_route53_zone.this.name
}
resource "aws_ses_domain_dkim" "this" {
domain = data.aws_route53_zone.this.name
}
resource "aws_ses_domain_mail_from" "this" {
domain = aws_ses_domain_identity.this.domain
mail_from_domain = "${var.mail_from_name}.${data.aws_route53_zone.this.name}"
}
resource "aws_route53_record" "this_amazonses_verification_record" {
zone_id = data.aws_route53_zone.this.zone_id
name = "_amazonses.${data.aws_route53_zone.this.name}"
type = "TXT"
ttl = var.ttl
records = [aws_ses_domain_identity.this.verification_token]
}
resource "aws_ses_domain_identity_verification" "this" {
domain = aws_ses_domain_identity.this.id
depends_on = [aws_route53_record.this_amazonses_verification_record]
}
resource "aws_route53_record" "this_mx" {
count = var.create_root_mx ? 1 : 0
zone_id = data.aws_route53_zone.this.zone_id
name = data.aws_route53_zone.this.name
type = "MX"
ttl = var.ttl
records = ["10 inbound-smtp.${data.aws_region.current.name}.amazonaws.com."]
}
resource "aws_route53_record" "this_autodiscover" {
count = var.create_root_autodiscover ? 1 : 0
zone_id = data.aws_route53_zone.this.zone_id
name = "autodiscover.${data.aws_route53_zone.this.name}"
type = "CNAME"
ttl = var.ttl
records = ["autodiscover.mail.${data.aws_region.current.name}.awsapps.com."]
}
resource "aws_route53_record" "this_amazonses_dkim_record" {
count = 3
zone_id = data.aws_route53_zone.this.zone_id
name = "${element(aws_ses_domain_dkim.this.dkim_tokens, count.index)}._domainkey"
type = "CNAME"
ttl = var.ttl
records = ["${element(aws_ses_domain_dkim.this.dkim_tokens, count.index)}.dkim.amazonses.com"]
}
resource "aws_route53_record" "this_amazonses_txt" {
count = var.create_root_txt == true ? 1 : 0
zone_id = data.aws_route53_zone.this.zone_id
name = data.aws_route53_zone.this.name
type = "TXT"
ttl = var.ttl
records = ["v=spf1 include:amazonses.com ~all"]
}
resource "aws_route53_record" "this_amazonses_dmarc_txt" {
zone_id = data.aws_route53_zone.this.zone_id
name = "_dmarc.${data.aws_route53_zone.this.name}"
type = "TXT"
ttl = var.ttl
records = ["v=DMARC1;p=quarantine;pct=100;fo=1"]
}
resource "aws_route53_record" "this_ses_domain_mail_from_mx" {
zone_id = data.aws_route53_zone.this.zone_id
name = aws_ses_domain_mail_from.this.mail_from_domain
type = "MX"
ttl = var.ttl
records = ["10 feedback-smtp.${data.aws_region.current.name}.amazonses.com"]
}
resource "aws_route53_record" "this_ses_domain_mail_from_txt" {
zone_id = data.aws_route53_zone.this.zone_id
name = aws_ses_domain_mail_from.this.mail_from_domain
type = "TXT"
ttl = var.ttl
records = ["v=spf1 include:amazonses.com -all"]
}