-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
69 lines (59 loc) · 1.98 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
data "aws_region" "current_ses" {}
data "aws_route53_zone" "domain" {
name = var.top_domain
}
resource "aws_ses_domain_identity" "ses_domain" {
domain = var.top_domain
}
resource "aws_route53_record" "amazonses_verification_record" {
zone_id = data.aws_route53_zone.domain.zone_id
name = "_amazonses.${var.top_domain}"
type = "TXT"
ttl = "1800"
records = [aws_ses_domain_identity.ses_domain.verification_token]
}
resource "aws_ses_domain_dkim" "ses_domain_dkim" {
domain = aws_ses_domain_identity.ses_domain.domain
}
resource "aws_ses_domain_mail_from" "ses-system" {
domain = var.top_domain
mail_from_domain = "mail.${var.top_domain}"
}
resource "aws_route53_record" "amazonses_dkim_record" {
count = 3
zone_id = data.aws_route53_zone.domain.zone_id
name = "${aws_ses_domain_dkim.ses_domain_dkim.dkim_tokens[count.index]}._domainkey.${var.top_domain}"
type = "CNAME"
ttl = "1800"
records = ["${aws_ses_domain_dkim.ses_domain_dkim.dkim_tokens[count.index]}.dkim.amazonses.com"]
}
resource "aws_route53_record" "ses-system-dmarc" {
zone_id = data.aws_route53_zone.domain.zone_id
name = "_dmarc.${var.top_domain}"
type = "TXT"
ttl = "600"
records = [
"v=DMARC1;p=reject;rua=mailto:${var.dmarc_mailto}"
]
}
resource "aws_route53_record" "ses-system-mail-from-spf" {
zone_id = data.aws_route53_zone.domain.zone_id
name = var.top_domain
type = "TXT"
ttl = "600"
records = ["v=spf1 include:amazonses.com -all"]
}
resource "aws_route53_record" "ses-system-mail-from-mx" {
zone_id = data.aws_route53_zone.domain.zone_id
name = "mail.${var.top_domain}"
type = "MX"
ttl = "600"
records = ["10 feedback-smtp.${data.aws_region.current_ses.id}.amazonses.com"]
}
resource "aws_route53_record" "ses-system-mail-from-spf-subdomain" {
zone_id = data.aws_route53_zone.domain.zone_id
name = "mail.${var.top_domain}"
type = "TXT"
ttl = "600"
records = ["v=spf1 include:amazonses.com -all"]
}