1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #Certificate
- resource "aws_acm_certificate" "cert" {
- domain_name = "${var.dns_name}${var.suffix}.${var.dns_info["public"]["zone"]}"
- validation_method = "DNS"
- lifecycle {
- create_before_destroy = true
- }
- provisioner "local-exec" {
- # For this purpose, the certificate is frequently not ready by the time
- # we attempt to use it. This buys a little time, but is a hack.
- command = "sleep 10"
- }
- tags = merge(local.standard_tags, var.tags)
- }
- resource "aws_acm_certificate_validation" "cert" {
- certificate_arn = aws_acm_certificate.cert.arn
- validation_record_fqdns = [for record in aws_route53_record.cert_validation : record.fqdn]
- }
- resource "aws_route53_record" "cert_validation" {
- provider = aws.mdr-common-services-commercial
- for_each = {
- for dvo in aws_acm_certificate.cert.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"]
- }
|