Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
add public hosted zone and wildcard certificate
  • Loading branch information
burib authored Nov 13, 2024
1 parent b72fb2c commit a8a15df
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
resource "aws_route53_zone" "this" {
name = var.domain
}

# Certificate
resource "aws_acm_certificate" "wildcard_cert" {
domain_name = aws_route53_zone.this.name
validation_method = "DNS"

subject_alternative_names = [
"*.${aws_route53_zone.this.name}"
]
}

resource "aws_acm_certificate_validation" "wildcard_cert" {
certificate_arn = aws_acm_certificate.wildcard_cert.arn
validation_record_fqdns = [
aws_route53_record.wildcard_cert_validation.fqdn
]
}

resource "aws_route53_record" "wildcard_cert_validation" {
name = tolist(aws_acm_certificate.wildcard_cert.domain_validation_options)[0].resource_record_name
type = tolist(aws_acm_certificate.wildcard_cert.domain_validation_options)[0].resource_record_type
zone_id = var.should_create_hosted_zone ? aws_route53_zone.hosted_zone.zone_id : aws_route53_zone.this.zone_id
records = [
tolist(aws_acm_certificate.wildcard_cert.domain_validation_options)[0].resource_record_value
]
ttl = "60"
}

0 comments on commit a8a15df

Please sign in to comment.