Skip to content

Commit

Permalink
Condition on data aws_route53_zone (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrpradojr authored Nov 2, 2021
1 parent 02425ca commit c1e0e59
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions route53.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
data "aws_route53_zone" "selected" {
name = var.hosted_zone
count = var.hostname_create && var.module_enabled ? 1 : 0
name = var.hosted_zone
}

resource "aws_route53_record" "hostname" {
count = var.hostname_create && var.module_enabled && var.hostname_alias == false ? length(var.hostnames) : 0

zone_id = data.aws_route53_zone.selected.zone_id
zone_id = data.aws_route53_zone.selected[0].zone_id
name = var.hostnames[count.index]
type = "CNAME"
ttl = "300"
Expand All @@ -15,7 +16,7 @@ resource "aws_route53_record" "hostname" {
resource "aws_route53_record" "hostname_alias" {
count = var.hostname_create && var.module_enabled && var.hostname_alias == true ? length(var.hostnames) : 0

zone_id = data.aws_route53_zone.selected.zone_id
zone_id = data.aws_route53_zone.selected[0].zone_id
name = var.hostnames[count.index]
type = "A"
alias {
Expand Down

0 comments on commit c1e0e59

Please sign in to comment.