2019-08-09 16:29:59 +00:00
|
|
|
locals {
|
|
|
|
cert_sans = [var.dns_domain]
|
|
|
|
}
|
|
|
|
|
2019-07-26 21:02:09 +00:00
|
|
|
resource "aws_acm_certificate" "main" {
|
2019-07-29 20:52:10 +00:00
|
|
|
domain_name = "${var.stage}.${var.dns_domain}"
|
|
|
|
|
2019-08-09 16:29:59 +00:00
|
|
|
subject_alternative_names = local.cert_sans
|
2019-07-26 21:02:09 +00:00
|
|
|
validation_method = "DNS"
|
2019-08-09 16:29:59 +00:00
|
|
|
|
|
|
|
tags = {
|
|
|
|
Name = "${var.stage}.${var.dns_domain}"
|
|
|
|
}
|
2019-07-26 21:02:09 +00:00
|
|
|
}
|
|
|
|
|
2019-07-30 17:27:15 +00:00
|
|
|
resource "gandi_zonerecord" "cert_verification" {
|
2019-08-09 16:29:59 +00:00
|
|
|
zone = var.gandi_zone_id
|
|
|
|
name = replace(aws_acm_certificate.main.domain_validation_options[count.index].resource_record_name, ".${var.dns_domain}.", "")
|
|
|
|
type = aws_acm_certificate.main.domain_validation_options[count.index].resource_record_type
|
2019-07-26 21:02:09 +00:00
|
|
|
ttl = 300
|
2019-08-09 16:29:59 +00:00
|
|
|
values = [aws_acm_certificate.main.domain_validation_options[count.index].resource_record_value]
|
|
|
|
count = length(local.cert_sans)+1
|
2019-07-26 21:02:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_acm_certificate_validation" "main" {
|
2019-07-30 18:36:52 +00:00
|
|
|
certificate_arn = aws_acm_certificate.main.arn
|
2019-08-09 16:29:59 +00:00
|
|
|
validation_record_fqdns = [
|
|
|
|
for verification in gandi_zonerecord.cert_verification:
|
|
|
|
"${verification.name}.${var.dns_domain}"
|
|
|
|
]
|
2019-07-26 21:02:09 +00:00
|
|
|
}
|