1234567891011121314151617181920212223242526272829303132333435363738 |
- #Certificate
- resource "aws_acm_certificate" "cert_hec" {
- count = local.alsi_hec_alb ? 1 : 0
- domain_name = "${var.prefix}-alsi-hec.${var.dns_info["public"]["zone"]}"
- validation_method = "DNS"
- lifecycle {
- create_before_destroy = true
- }
- tags = merge(local.standard_tags, var.tags)
- }
- resource "aws_acm_certificate_validation" "cert_hec" {
- count = local.alsi_hec_alb ? 1 : 0
- certificate_arn = aws_acm_certificate.cert_hec[count.index].arn
- validation_record_fqdns = [for record in aws_route53_record.cert_hec_validation : record.fqdn]
- }
- resource "aws_route53_record" "cert_hec_validation" {
- provider = aws.mdr-common-services-commercial
- # This syntax is tricky. If the bool is true, then we create the for_each map, otherwise we do an empty map.
- for_each = local.alsi_hec_alb ? {
- for dvo in aws_acm_certificate.cert_hec[0].domain_validation_options : dvo.domain_name => {
- name = dvo.resource_record_name
- record = dvo.resource_record_value
- type = dvo.resource_record_type
- }
- } : {}
- allow_overwrite = true
- name = each.value.name
- records = [each.value.record]
- ttl = 60
- type = each.value.type
- zone_id = var.dns_info["public"]["zone_id"]
- }
|