Skip to content

Commit b6e1cf8

Browse files
change conditional for advertised_ip_ranges
1 parent 7f6644d commit b6e1cf8

File tree

2 files changed

+48
-48
lines changed
  • 3-networks-hub-and-spoke/modules

2 files changed

+48
-48
lines changed

3-networks-hub-and-spoke/modules/base_shared_vpc/main.tf

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ module "region1_router1" {
124124
network = module.main.network_name
125125
region = var.default_region1
126126
bgp = {
127-
asn = var.bgp_asn_subnet
128-
advertised_groups = ["ALL_SUBNETS"]
129-
advertised_ip_ranges = [
130-
{ range = local.private_googleapis_cidr },
131-
{ range = "35.199.192.0/19" }
132-
]
127+
asn = var.bgp_asn_subnet
128+
advertised_groups = ["ALL_SUBNETS"]
129+
advertised_ip_ranges = concat(
130+
[{ range = local.private_googleapis_cidr }],
131+
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
132+
)
133133
}
134134
}
135135

@@ -143,12 +143,12 @@ module "region1_router2" {
143143
network = module.main.network_name
144144
region = var.default_region1
145145
bgp = {
146-
asn = var.bgp_asn_subnet
147-
advertised_groups = ["ALL_SUBNETS"]
148-
advertised_ip_ranges = [
149-
{ range = local.private_googleapis_cidr },
150-
{ range = "35.199.192.0/19" }
151-
]
146+
asn = var.bgp_asn_subnet
147+
advertised_groups = ["ALL_SUBNETS"]
148+
advertised_ip_ranges = concat(
149+
[{ range = local.private_googleapis_cidr }],
150+
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
151+
)
152152
}
153153
}
154154

@@ -162,12 +162,12 @@ module "region2_router1" {
162162
network = module.main.network_name
163163
region = var.default_region2
164164
bgp = {
165-
asn = var.bgp_asn_subnet
166-
advertised_groups = ["ALL_SUBNETS"]
167-
advertised_ip_ranges = [
168-
{ range = local.private_googleapis_cidr },
169-
{ range = "35.199.192.0/19" }
170-
]
165+
asn = var.bgp_asn_subnet
166+
advertised_groups = ["ALL_SUBNETS"]
167+
advertised_ip_ranges = concat(
168+
[{ range = local.private_googleapis_cidr }],
169+
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
170+
)
171171
}
172172
}
173173

@@ -181,11 +181,11 @@ module "region2_router2" {
181181
network = module.main.network_name
182182
region = var.default_region2
183183
bgp = {
184-
asn = var.bgp_asn_subnet
185-
advertised_groups = ["ALL_SUBNETS"]
186-
advertised_ip_ranges = [
187-
{ range = local.private_googleapis_cidr },
188-
{ range = "35.199.192.0/19" }
189-
]
184+
asn = var.bgp_asn_subnet
185+
advertised_groups = ["ALL_SUBNETS"]
186+
advertised_ip_ranges = concat(
187+
[{ range = local.private_googleapis_cidr }],
188+
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
189+
)
190190
}
191191
}

3-networks-hub-and-spoke/modules/restricted_shared_vpc/main.tf

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ module "region1_router1" {
128128
network = module.main.network_name
129129
region = var.default_region1
130130
bgp = {
131-
asn = var.bgp_asn_subnet
132-
advertised_groups = ["ALL_SUBNETS"]
133-
advertised_ip_ranges = [
134-
{ range = local.restricted_googleapis_cidr },
135-
{ range = "35.199.192.0/19" }
136-
]
131+
asn = var.bgp_asn_subnet
132+
advertised_groups = ["ALL_SUBNETS"]
133+
advertised_ip_ranges = concat(
134+
[{ range = local.restricted_googleapis_cidr }],
135+
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
136+
)
137137
}
138138
}
139139

@@ -147,12 +147,12 @@ module "region1_router2" {
147147
network = module.main.network_name
148148
region = var.default_region1
149149
bgp = {
150-
asn = var.bgp_asn_subnet
151-
advertised_groups = ["ALL_SUBNETS"]
152-
advertised_ip_ranges = [
153-
{ range = local.restricted_googleapis_cidr },
154-
{ range = "35.199.192.0/19" }
155-
]
150+
asn = var.bgp_asn_subnet
151+
advertised_groups = ["ALL_SUBNETS"]
152+
advertised_ip_ranges = concat(
153+
[{ range = local.restricted_googleapis_cidr }],
154+
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
155+
)
156156
}
157157
}
158158

@@ -166,12 +166,12 @@ module "region2_router1" {
166166
network = module.main.network_name
167167
region = var.default_region2
168168
bgp = {
169-
asn = var.bgp_asn_subnet
170-
advertised_groups = ["ALL_SUBNETS"]
171-
advertised_ip_ranges = [
172-
{ range = local.restricted_googleapis_cidr },
173-
{ range = "35.199.192.0/19" }
174-
]
169+
asn = var.bgp_asn_subnet
170+
advertised_groups = ["ALL_SUBNETS"]
171+
advertised_ip_ranges = concat(
172+
[{ range = local.restricted_googleapis_cidr }],
173+
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
174+
)
175175
}
176176
}
177177

@@ -185,11 +185,11 @@ module "region2_router2" {
185185
network = module.main.network_name
186186
region = var.default_region2
187187
bgp = {
188-
asn = var.bgp_asn_subnet
189-
advertised_groups = ["ALL_SUBNETS"]
190-
advertised_ip_ranges = [
191-
{ range = local.restricted_googleapis_cidr },
192-
{ range = "35.199.192.0/19" }
193-
]
188+
asn = var.bgp_asn_subnet
189+
advertised_groups = ["ALL_SUBNETS"]
190+
advertised_ip_ranges = concat(
191+
[{ range = local.restricted_googleapis_cidr }],
192+
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
193+
)
194194
}
195195
}

0 commit comments

Comments
 (0)