42 lines
1.0 KiB
HCL
42 lines
1.0 KiB
HCL
locals {
|
|
domain_name = "test.co"
|
|
}
|
|
|
|
resource "aws_route53_zone" "test" {
|
|
name = local.domain_name
|
|
}
|
|
|
|
resource "aws_acm_certificate" "certificate" {
|
|
domain_name = local.domain_name
|
|
validation_method = "DNS"
|
|
|
|
subject_alternative_names = ["*.${local.domain_name}"]
|
|
|
|
lifecycle {
|
|
create_before_destroy = true
|
|
}
|
|
}
|
|
|
|
resource "aws_route53_record" "certificate_validation" {
|
|
for_each = {
|
|
for dvo in aws_acm_certificate.certificate.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 = aws_route53_zone.test.zone_id
|
|
}
|
|
|
|
resource "aws_acm_certificate_validation" "validation" {
|
|
certificate_arn = aws_acm_certificate.certificate.arn
|
|
validation_record_fqdns = [
|
|
for record in aws_route53_record.certificate_validation : record.fqdn
|
|
]
|
|
} |