-
Notifications
You must be signed in to change notification settings - Fork 2
/
email.tf
52 lines (44 loc) · 1.33 KB
/
email.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
resource "aws_ses_domain_identity" "stack_domain_identity" {
domain = local.public_zone_name
}
resource "aws_ses_domain_dkim" "stack_domain_dkim" {
domain = aws_ses_domain_identity.stack_domain_identity.domain
}
resource "aws_route53_record" "stack_amazonses_dkim_verification_record" {
count = 3
zone_id = module.dns.public_zone_id
name = "${element(
aws_ses_domain_dkim.stack_domain_dkim.dkim_tokens,
count.index,
)}._domainkey.${aws_ses_domain_identity.stack_domain_identity.domain}"
type = "CNAME"
ttl = "600"
records = ["${element(
aws_ses_domain_dkim.stack_domain_dkim.dkim_tokens,
count.index,
)}.dkim.amazonses.com"]
}
data "aws_iam_policy_document" "send_email" {
statement {
sid = "1"
actions = [
"ses:Send*",
]
resources = [
"*",
]
}
}
resource "aws_iam_policy" "send_email" {
name = "${local.namespace}-send-email"
path = "/"
description = "Allow stack resources to send email"
policy = data.aws_iam_policy_document.send_email.json
}
resource "aws_route53_record" "stack_amazonses_verification_record" {
zone_id = module.dns.public_zone_id
name = "_amazonses.${aws_ses_domain_identity.stack_domain_identity.id}"
type = "TXT"
ttl = "600"
records = [aws_ses_domain_identity.stack_domain_identity.verification_token]
}