Skip to content

Commit

Permalink
Merge pull request #1 from zelenkovsky/master
Browse files Browse the repository at this point in the history
Update to support new terraform 0.14.9 syntax.
  • Loading branch information
trebidav authored Dec 6, 2022
2 parents ed56465 + c3d34d9 commit 4009591
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions acm.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "aws_acm_certificate" "cert" {
domain_name = "${var.zone}"
domain_name = var.zone
validation_method = "DNS"
subject_alternative_names = ["www.${var.zone}"]

Expand All @@ -10,5 +10,5 @@ resource "aws_acm_certificate" "cert" {

resource "aws_acm_certificate_validation" "validation" {
certificate_arn = aws_acm_certificate.cert.arn
validation_record_fqdns = [aws_route53_record.cert_validation_1.fqdn, aws_route53_record.cert_validation_2.fqdn]
validation_record_fqdns = [ for record in aws_route53_record.cert_validation: record.fqdn ]
}
2 changes: 1 addition & 1 deletion cloudfront.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resource "aws_cloudfront_distribution" "redirect" {
enabled = true
is_ipv6_enabled = false

aliases = ["www.${var.zone}", "${var.zone}"]
aliases = ["www.${var.zone}", var.zone]

restrictions {
geo_restriction {
Expand Down
23 changes: 12 additions & 11 deletions route53.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ resource "aws_route53_record" "redirect" {
}
}

resource "aws_route53_record" "cert_validation_1" {
name = aws_acm_certificate.cert.domain_validation_options.0.resource_record_name
type = aws_acm_certificate.cert.domain_validation_options.0.resource_record_type
resource "aws_route53_record" "cert_validation" {
# https://github.com/hashicorp/terraform-provider-aws/issues/10098#issuecomment-663562342
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
}
}
name = each.value.name
records = [ each.value.record ]
type = each.value.type
zone_id = data.aws_route53_zone.zone.zone_id
records = [aws_acm_certificate.cert.domain_validation_options.0.resource_record_value]
ttl = 60
}

resource "aws_route53_record" "cert_validation_2" {
name = aws_acm_certificate.cert.domain_validation_options.1.resource_record_name
type = aws_acm_certificate.cert.domain_validation_options.1.resource_record_type
zone_id = data.aws_route53_zone.zone.zone_id
records = [aws_acm_certificate.cert.domain_validation_options.1.resource_record_value]
ttl = 60
}

0 comments on commit 4009591

Please sign in to comment.