Skip to content

Commit 528b373

Browse files
authored
fix: allow enable_private_endpoint with no master_authorized_networks (#2058)
1 parent f67f416 commit 528b373

File tree

24 files changed

+22
-83
lines changed

24 files changed

+22
-83
lines changed

autogen/main/cluster.tf.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,10 @@ resource "google_container_cluster" "primary" {
257257
enable_autopilot = true
258258
{% endif %}
259259
dynamic "master_authorized_networks_config" {
260-
for_each = local.master_authorized_networks_config
260+
for_each = {% if private_cluster %}var.enable_private_endpoint || {% endif %}length(var.master_authorized_networks) > 0 ? [true] : []
261261
content {
262262
dynamic "cidr_blocks" {
263-
for_each = master_authorized_networks_config.value.cidr_blocks
263+
for_each = var.master_authorized_networks
264264
content {
265265
cidr_block = lookup(cidr_blocks.value, "cidr_block", "")
266266
display_name = lookup(cidr_blocks.value, "display_name", "")

autogen/main/main.tf.tmpl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,6 @@ locals {
174174

175175
# /BETA features
176176
{% endif %}
177-
178-
master_authorized_networks_config = length(var.master_authorized_networks) == 0 ? [] : [{
179-
cidr_blocks : var.master_authorized_networks
180-
}]
181-
182177
{% if autopilot_cluster != true %}
183178
cluster_output_node_pools_names = concat(
184179
[for np in google_container_node_pool.pools : np.name], [""],

cluster.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ resource "google_container_cluster" "primary" {
190190
enable_cilium_clusterwide_network_policy = var.enable_cilium_clusterwide_network_policy
191191

192192
dynamic "master_authorized_networks_config" {
193-
for_each = local.master_authorized_networks_config
193+
for_each = length(var.master_authorized_networks) > 0 ? [true] : []
194194
content {
195195
dynamic "cidr_blocks" {
196-
for_each = master_authorized_networks_config.value.cidr_blocks
196+
for_each = var.master_authorized_networks
197197
content {
198198
cidr_block = lookup(cidr_blocks.value, "cidr_block", "")
199199
display_name = lookup(cidr_blocks.value, "display_name", "")

examples/simple_autopilot_private/main.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,4 @@ module "gke" {
5151
enable_private_nodes = true
5252
network_tags = [local.cluster_type]
5353
deletion_protection = false
54-
55-
master_authorized_networks = [
56-
{
57-
cidr_block = "10.60.0.0/17"
58-
display_name = "VPC"
59-
},
60-
]
6154
}

main.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ locals {
126126
cluster_output_intranode_visbility_enabled = google_container_cluster.primary.enable_intranode_visibility
127127
cluster_output_identity_service_enabled = google_container_cluster.primary.identity_service_config != null && length(google_container_cluster.primary.identity_service_config) == 1 ? google_container_cluster.primary.identity_service_config[0].enabled : false
128128

129-
130-
master_authorized_networks_config = length(var.master_authorized_networks) == 0 ? [] : [{
131-
cidr_blocks : var.master_authorized_networks
132-
}]
133-
134129
cluster_output_node_pools_names = concat(
135130
[for np in google_container_node_pool.pools : np.name], [""],
136131
[for np in google_container_node_pool.windows_pools : np.name], [""]

modules/beta-autopilot-private-cluster/cluster.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ resource "google_container_cluster" "primary" {
106106
enable_fqdn_network_policy = var.enable_fqdn_network_policy
107107
enable_autopilot = true
108108
dynamic "master_authorized_networks_config" {
109-
for_each = local.master_authorized_networks_config
109+
for_each = var.enable_private_endpoint || length(var.master_authorized_networks) > 0 ? [true] : []
110110
content {
111111
dynamic "cidr_blocks" {
112-
for_each = master_authorized_networks_config.value.cidr_blocks
112+
for_each = var.master_authorized_networks
113113
content {
114114
cidr_block = lookup(cidr_blocks.value, "cidr_block", "")
115115
display_name = lookup(cidr_blocks.value, "display_name", "")

modules/beta-autopilot-private-cluster/main.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ locals {
101101

102102
# /BETA features
103103

104-
master_authorized_networks_config = length(var.master_authorized_networks) == 0 ? [] : [{
105-
cidr_blocks : var.master_authorized_networks
106-
}]
107-
108-
109104
cluster_master_auth_list_layer1 = local.cluster_output_master_auth
110105
cluster_master_auth_list_layer2 = local.cluster_master_auth_list_layer1[0]
111106
cluster_master_auth_map = local.cluster_master_auth_list_layer2[0]

modules/beta-autopilot-public-cluster/cluster.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ resource "google_container_cluster" "primary" {
106106
enable_fqdn_network_policy = var.enable_fqdn_network_policy
107107
enable_autopilot = true
108108
dynamic "master_authorized_networks_config" {
109-
for_each = local.master_authorized_networks_config
109+
for_each = length(var.master_authorized_networks) > 0 ? [true] : []
110110
content {
111111
dynamic "cidr_blocks" {
112-
for_each = master_authorized_networks_config.value.cidr_blocks
112+
for_each = var.master_authorized_networks
113113
content {
114114
cidr_block = lookup(cidr_blocks.value, "cidr_block", "")
115115
display_name = lookup(cidr_blocks.value, "display_name", "")

modules/beta-autopilot-public-cluster/main.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ locals {
100100

101101
# /BETA features
102102

103-
master_authorized_networks_config = length(var.master_authorized_networks) == 0 ? [] : [{
104-
cidr_blocks : var.master_authorized_networks
105-
}]
106-
107-
108103
cluster_master_auth_list_layer1 = local.cluster_output_master_auth
109104
cluster_master_auth_list_layer2 = local.cluster_master_auth_list_layer1[0]
110105
cluster_master_auth_map = local.cluster_master_auth_list_layer2[0]

modules/beta-private-cluster-update-variant/cluster.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ resource "google_container_cluster" "primary" {
211211

212212
enable_fqdn_network_policy = var.enable_fqdn_network_policy
213213
dynamic "master_authorized_networks_config" {
214-
for_each = local.master_authorized_networks_config
214+
for_each = var.enable_private_endpoint || length(var.master_authorized_networks) > 0 ? [true] : []
215215
content {
216216
dynamic "cidr_blocks" {
217-
for_each = master_authorized_networks_config.value.cidr_blocks
217+
for_each = var.master_authorized_networks
218218
content {
219219
cidr_block = lookup(cidr_blocks.value, "cidr_block", "")
220220
display_name = lookup(cidr_blocks.value, "display_name", "")

0 commit comments

Comments
 (0)