Skip to content

Instantly share code, notes, and snippets.

@david7482
Last active November 19, 2021 03:27
Show Gist options
  • Save david7482/8fb0322fe7b6ed6039059cc927369dd1 to your computer and use it in GitHub Desktop.
Save david7482/8fb0322fe7b6ed6039059cc927369dd1 to your computer and use it in GitHub Desktop.
resource "aws_acm_certificate" "cert" {
provider = aws.us-east-1
domain_name = var.fqdn
validation_method = "DNS"
}
resource "aws_route53_record" "cert_validation" {
provider = aws.us-east-1
name = tolist(aws_acm_certificate.cert.domain_validation_options)[0].resource_record_name
records = [tolist(aws_acm_certificate.cert.domain_validation_options)[0].resource_record_value]
type = tolist(aws_acm_certificate.cert.domain_validation_options)[0].resource_record_type
zone_id = data.aws_route53_zone.main.id
ttl = 60
}
resource "aws_acm_certificate_validation" "cert" {
provider = aws.us-east-1
certificate_arn = aws_acm_certificate.cert.arn
validation_record_fqdns = [aws_route53_record.cert_validation.fqdn]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment