Skip to content

Commit 1411d06

Browse files
authored
Revert "Allow management of ACM certs with SANs in multiple zones (#61)" (#66)
This reverts commit 2eec7e5.
1 parent 8d052a6 commit 1411d06

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

main.tf

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
locals {
22
enabled = module.this.enabled
3+
zone_name = var.zone_name == "" ? "${var.domain_name}." : var.zone_name
34
process_domain_validation_options = local.enabled && var.process_domain_validation_options && var.validation_method == "DNS"
45
domain_validation_options_set = local.process_domain_validation_options ? aws_acm_certificate.default[0].domain_validation_options : toset([])
56
public_enabled = var.certificate_authority_arn == null
6-
private_enabled = !local.public_enabled
7-
8-
all_domains = concat(
9-
[var.domain_name],
10-
var.subject_alternative_names
11-
)
12-
domain_to_zone = {
13-
for domain in local.all_domains :
14-
domain => length(split(".", domain)) > 2 ? join(".", slice(split(".", domain), 1, length(split(".", domain)))) : domain
15-
}
16-
unique_zones = distinct(values(local.domain_to_zone))
7+
private_enabled = ! local.public_enabled
178
}
189

1910
resource "aws_acm_certificate" "default" {
@@ -37,9 +28,9 @@ resource "aws_acm_certificate" "default" {
3728
}
3829

3930
data "aws_route53_zone" "default" {
40-
for_each = local.process_domain_validation_options ? toset(local.unique_zones) : toset([])
31+
count = local.process_domain_validation_options ? 1 : 0
4132
zone_id = var.zone_id
42-
name = try(length(var.zone_id), 0) == 0 ? (var.zone_name == "" ? each.key : var.zone_name) : null
33+
name = try(length(var.zone_id), 0) == 0 ? local.zone_name : null
4334
private_zone = local.private_enabled
4435
}
4536

@@ -51,7 +42,7 @@ resource "aws_route53_record" "default" {
5142
type = dvo.resource_record_type
5243
}
5344
}
54-
zone_id = data.aws_route53_zone.default[local.domain_to_zone[each.key]].id
45+
zone_id = join("", data.aws_route53_zone.default.*.zone_id)
5546
ttl = var.ttl
5647
allow_overwrite = true
5748
name = each.value.name

0 commit comments

Comments
 (0)