-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
38 lines (32 loc) · 1.16 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
data "aws_route53_zone" "selected_zone" {
count = var.is_automatic_verify_acms ? 1 : 0
name = var.route53_zone_name
private_zone = false
}
resource "aws_acm_certificate" "this" {
for_each = var.acms_domain_name
domain_name = lookup(each.value, "domain_name", null)
subject_alternative_names = lookup(each.value, "subject_alternative_names", [])
validation_method = "DNS"
tags = local.tags
}
resource "aws_route53_record" "this" {
for_each = local.domains_validation_options_set
allow_overwrite = true
name = each.value.resource_record_name
records = [each.value.resource_record_value]
ttl = 60
type = each.value.resource_record_type
zone_id = data.aws_route53_zone.selected_zone[0].zone_id
depends_on = [
aws_acm_certificate.this
]
}
resource "aws_acm_certificate_validation" "this" {
for_each = local.domains_validation_options_set
certificate_arn = each.value.acm_arn
validation_record_fqdns = values(aws_route53_record.this)[*].fqdn
depends_on = [
aws_route53_record.this
]
}