Skip to content

Commit

Permalink
Revert "Allow management of ACM certs with SANs in multiple zones (#61)"
Browse files Browse the repository at this point in the history
This reverts commit 2eec7e5.
  • Loading branch information
nitrocode committed Mar 3, 2023
1 parent 2eec7e5 commit 45cfd80
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
locals {
enabled = module.this.enabled
zone_name = var.zone_name == "" ? "${var.domain_name}." : var.zone_name
process_domain_validation_options = local.enabled && var.process_domain_validation_options && var.validation_method == "DNS"
domain_validation_options_set = local.process_domain_validation_options ? aws_acm_certificate.default.0.domain_validation_options : toset([])
public_enabled = var.certificate_authority_arn == null
private_enabled = ! local.public_enabled

all_domains = concat(
[var.domain_name],
var.subject_alternative_names
)
domain_to_zone = {
for domain in local.all_domains :
domain => join(".", slice(split(".", domain), 1, length(split(".", domain))))
}
unique_zones = distinct(values(local.domain_to_zone))
}

resource "aws_acm_certificate" "default" {
Expand All @@ -36,9 +27,9 @@ resource "aws_acm_certificate" "default" {
}

data "aws_route53_zone" "default" {
for_each = local.process_domain_validation_options ? toset(local.unique_zones) : toset([])
count = local.process_domain_validation_options ? 1 : 0
zone_id = var.zone_id
name = try(length(var.zone_id), 0) == 0 ? (var.zone_name == "" ? each.key : var.zone_name) : null
name = try(length(var.zone_id), 0) == 0 ? local.zone_name : null
private_zone = local.private_enabled
}

Expand All @@ -50,7 +41,7 @@ resource "aws_route53_record" "default" {
type = dvo.resource_record_type
}
}
zone_id = data.aws_route53_zone.default[local.domain_to_zone[each.key]].id
zone_id = join("", data.aws_route53_zone.default.*.zone_id)
ttl = var.ttl
allow_overwrite = true
name = each.value.name
Expand Down

0 comments on commit 45cfd80

Please sign in to comment.