-
Notifications
You must be signed in to change notification settings - Fork 2
/
validation.tf
40 lines (33 loc) · 1.83 KB
/
validation.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
locals {
alternative_names_count = "${length(var.subject_alternative_names)}"
}
data "aws_route53_zone" "zone" {
count = "${local.alternative_names_count}"
name = "${lookup(var.subject_alternative_names[count.index], "hosted_zone_name")}"
private_zone = false
}
resource "aws_route53_record" "cert_validation" {
count = "${local.alternative_names_count}"
name = "${lookup(aws_acm_certificate.cert.domain_validation_options[count.index], "resource_record_name")}"
type = "${lookup(aws_acm_certificate.cert.domain_validation_options[count.index], "resource_record_type")}"
zone_id = "${data.aws_route53_zone.zone.*.id[count.index]}"
records = ["${lookup(aws_acm_certificate.cert.domain_validation_options[count.index], "resource_record_value")}"]
ttl = 60
}
data "aws_route53_zone" "domain_zone" {
count = "${var.create_entry_for_domain ? 1 : 0}"
name = "${var.domain_name}."
private_zone = false
}
resource "aws_route53_record" "cert_domain_validation" {
count = "${var.create_entry_for_domain ? 1 : 0}"
name = "${lookup(aws_acm_certificate.cert.domain_validation_options[length(aws_acm_certificate.cert.domain_validation_options) - 1], "resource_record_name")}"
type = "${lookup(aws_acm_certificate.cert.domain_validation_options[length(aws_acm_certificate.cert.domain_validation_options) - 1], "resource_record_type")}"
zone_id = "${data.aws_route53_zone.domain_zone[count.index]}"
records = ["${lookup(aws_acm_certificate.cert.domain_validation_options[length(aws_acm_certificate.cert.domain_validation_options) - 1], "resource_record_value")}"]
ttl = 60
}
resource "aws_acm_certificate_validation" "cert" {
certificate_arn = "${aws_acm_certificate.cert.arn}"
depends_on = ["aws_route53_record.cert_validation", "aws_route53_record.cert_domain_validation"]
}