Skip to content

Commit

Permalink
- route53-zone-association
Browse files Browse the repository at this point in the history
  - fix zone_ids to remove null
  • Loading branch information
badra001 committed Jun 28, 2023
1 parent 06b2618 commit 3a44851
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,7 @@
- vpn-transit-gateway
- add ok_action, update template, add version to description
- add composite alarms for whole site and all tunnels

* 2.9.2 -- 2023-06-28
- route53-zone-association
- fix zone_ids to remove null
2 changes: 1 addition & 1 deletion common/version.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
locals {
_module_version = "2.9.1"
_module_version = "2.9.2"
_module_names = {
"_main_" = "aws-vpc-setup"

Expand Down
4 changes: 3 additions & 1 deletion examples/full-setup-tf-upgrade/tf-run.destroy.data
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION 1.0.5
VERSION 1.0.7
BACKUP-STATE
COMMAND tf-init
COMMAND tf-state list
Expand All @@ -14,6 +14,8 @@ module.base-security-groups
module.flowlogs
module.vpn
module.routing
module.vpce module.routing_attachment
module.subnets
module.vpc
# mv vpc-transit-gateway.tf vpc-transit-gateway.tf.off
ALL
5 changes: 3 additions & 2 deletions route53-zone-association/vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@ locals {
"boc:tf_module_name" = lookup(local._module_names, local._module_name, local._module_names["_main_"])
"boc:created_by" = "terraform"
}
zone_ids = compact(var.zone_ids)
}

#---
# zone ids
#---
resource "aws_route53_vpc_association_authorization" "peer_zone" {
provider = aws.peer
for_each = data.aws_caller_identity.self.account_id != data.aws_caller_identity.peer.account_id ? toset(var.zone_ids) : toset([])
for_each = data.aws_caller_identity.self.account_id != data.aws_caller_identity.peer.account_id ? toset(local.zone_ids) : toset([])
zone_id = each.key
vpc_region = var.region == null ? data.aws_region.self.name : var.region
vpc_id = var.vpc_id
}

resource "aws_route53_zone_association" "peer_zone" {
provider = aws.self
for_each = toset(var.zone_ids)
for_each = toset(local.zone_ids)

zone_id = each.key
vpc_id = var.vpc_id
Expand Down
7 changes: 4 additions & 3 deletions route53-zone-association/zone/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@ locals {
"boc:tf_module_name" = lookup(local._module_names, local._module_name, local._module_names["_main_"])
"boc:created_by" = "terraform"
}
zone_ids = compact(var.zone_ids)
}

resource "aws_route53_vpc_association_authorization" "self_zone" {
provider = aws.self
for_each = data.aws_caller_identity.self.account_id != data.aws_caller_identity.peer.account_id ? toset(var.zone_ids) : toset([])
for_each = data.aws_caller_identity.self.account_id != data.aws_caller_identity.peer.account_id ? toset(local.zone_ids) : toset([])
zone_id = each.key
vpc_region = var.region == null ? data.aws_region.peer.name : var.region
vpc_id = var.vpc_id
}

resource "aws_route53_zone_association" "self_zone" {
provider = aws.peer
for_each = toset(var.zone_ids)
for_each = toset(local.zone_ids)

zone_id = each.key
vpc_id = var.vpc_id
Expand All @@ -41,7 +42,7 @@ resource "aws_route53_zone_association" "self_zone" {
#---
data "aws_route53_zone" "zones" {
provider = aws.self
for_each = toset(var.zone_ids)
for_each = toset(local.zone_ids)
zone_id = each.key
private_zone = var.private_zone
}
Expand Down

0 comments on commit 3a44851

Please sign in to comment.