Skip to content

Commit 552b3f4

Browse files
yuval2313apeabody
andauthored
fix: Invalid index for google_container_cluster.primary.private_cluster_config[0] (#2354)
Co-authored-by: Andrew Peabody <[email protected]>
1 parent 40b83a6 commit 552b3f4

File tree

16 files changed

+112
-16
lines changed

16 files changed

+112
-16
lines changed

autogen/main/main.tf.tmpl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,13 @@ locals {
147147
{% if private_cluster %}
148148
cluster_endpoint = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? (var.enable_private_endpoint || var.deploy_using_private_endpoint ? google_container_cluster.primary.private_cluster_config[0].private_endpoint : google_container_cluster.primary.private_cluster_config[0].public_endpoint) : google_container_cluster.primary.endpoint
149149
cluster_peering_name = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? google_container_cluster.primary.private_cluster_config[0].peering_name : null
150-
cluster_endpoint_for_nodes = google_container_cluster.primary.private_cluster_config[0].master_ipv4_cidr_block
150+
cluster_endpoint_for_nodes = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? (
151+
var.private_endpoint_subnetwork != null ?
152+
data.google_compute_subnetwork.private_endpoint_subnetwork[0].ip_cidr_range :
153+
var.master_ipv4_cidr_block != null ?
154+
google_container_cluster.primary.private_cluster_config[0].master_ipv4_cidr_block :
155+
local.cluster_subnet_cidr
156+
) : local.cluster_subnet_cidr
151157
{% else %}
152158
cluster_endpoint = google_container_cluster.primary.endpoint
153159
cluster_endpoint_for_nodes = "${google_container_cluster.primary.endpoint}/32"

autogen/main/networks.tf.tmpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,14 @@ data "google_compute_subnetwork" "gke_subnetwork" {
2424
region = local.region
2525
project = local.network_project_id
2626
}
27+
28+
{% if private_cluster %}
29+
data "google_compute_subnetwork" "private_endpoint_subnetwork" {
30+
provider = google
31+
32+
count = var.private_endpoint_subnetwork != null ? 1 : 0
33+
name = var.private_endpoint_subnetwork
34+
region = local.region
35+
project = local.network_project_id
36+
}
37+
{% endif %}

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,15 @@ locals {
7676
cluster_output_regional_zones = google_container_cluster.primary.node_locations
7777
cluster_output_zones = local.cluster_output_regional_zones
7878

79-
cluster_endpoint = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? (var.enable_private_endpoint || var.deploy_using_private_endpoint ? google_container_cluster.primary.private_cluster_config[0].private_endpoint : google_container_cluster.primary.private_cluster_config[0].public_endpoint) : google_container_cluster.primary.endpoint
80-
cluster_peering_name = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? google_container_cluster.primary.private_cluster_config[0].peering_name : null
81-
cluster_endpoint_for_nodes = google_container_cluster.primary.private_cluster_config[0].master_ipv4_cidr_block
79+
cluster_endpoint = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? (var.enable_private_endpoint || var.deploy_using_private_endpoint ? google_container_cluster.primary.private_cluster_config[0].private_endpoint : google_container_cluster.primary.private_cluster_config[0].public_endpoint) : google_container_cluster.primary.endpoint
80+
cluster_peering_name = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? google_container_cluster.primary.private_cluster_config[0].peering_name : null
81+
cluster_endpoint_for_nodes = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? (
82+
var.private_endpoint_subnetwork != null ?
83+
data.google_compute_subnetwork.private_endpoint_subnetwork[0].ip_cidr_range :
84+
var.master_ipv4_cidr_block != null ?
85+
google_container_cluster.primary.private_cluster_config[0].master_ipv4_cidr_block :
86+
local.cluster_subnet_cidr
87+
) : local.cluster_subnet_cidr
8288

8389
cluster_output_master_auth = concat(google_container_cluster.primary[*].master_auth, [])
8490
cluster_output_master_version = google_container_cluster.primary.master_version

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ data "google_compute_subnetwork" "gke_subnetwork" {
2424
region = local.region
2525
project = local.network_project_id
2626
}
27+
28+
data "google_compute_subnetwork" "private_endpoint_subnetwork" {
29+
provider = google
30+
31+
count = var.private_endpoint_subnetwork != null ? 1 : 0
32+
name = var.private_endpoint_subnetwork
33+
region = local.region
34+
project = local.network_project_id
35+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ data "google_compute_subnetwork" "gke_subnetwork" {
2424
region = local.region
2525
project = local.network_project_id
2626
}
27+

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,15 @@ locals {
122122
cluster_output_regional_zones = google_container_cluster.primary.node_locations
123123
cluster_output_zones = local.cluster_output_regional_zones
124124

125-
cluster_endpoint = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? (var.enable_private_endpoint || var.deploy_using_private_endpoint ? google_container_cluster.primary.private_cluster_config[0].private_endpoint : google_container_cluster.primary.private_cluster_config[0].public_endpoint) : google_container_cluster.primary.endpoint
126-
cluster_peering_name = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? google_container_cluster.primary.private_cluster_config[0].peering_name : null
127-
cluster_endpoint_for_nodes = google_container_cluster.primary.private_cluster_config[0].master_ipv4_cidr_block
125+
cluster_endpoint = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? (var.enable_private_endpoint || var.deploy_using_private_endpoint ? google_container_cluster.primary.private_cluster_config[0].private_endpoint : google_container_cluster.primary.private_cluster_config[0].public_endpoint) : google_container_cluster.primary.endpoint
126+
cluster_peering_name = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? google_container_cluster.primary.private_cluster_config[0].peering_name : null
127+
cluster_endpoint_for_nodes = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? (
128+
var.private_endpoint_subnetwork != null ?
129+
data.google_compute_subnetwork.private_endpoint_subnetwork[0].ip_cidr_range :
130+
var.master_ipv4_cidr_block != null ?
131+
google_container_cluster.primary.private_cluster_config[0].master_ipv4_cidr_block :
132+
local.cluster_subnet_cidr
133+
) : local.cluster_subnet_cidr
128134

129135
cluster_output_master_auth = concat(google_container_cluster.primary[*].master_auth, [])
130136
cluster_output_master_version = google_container_cluster.primary.master_version

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ data "google_compute_subnetwork" "gke_subnetwork" {
2424
region = local.region
2525
project = local.network_project_id
2626
}
27+
28+
data "google_compute_subnetwork" "private_endpoint_subnetwork" {
29+
provider = google
30+
31+
count = var.private_endpoint_subnetwork != null ? 1 : 0
32+
name = var.private_endpoint_subnetwork
33+
region = local.region
34+
project = local.network_project_id
35+
}

modules/beta-private-cluster/main.tf

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,15 @@ locals {
122122
cluster_output_regional_zones = google_container_cluster.primary.node_locations
123123
cluster_output_zones = local.cluster_output_regional_zones
124124

125-
cluster_endpoint = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? (var.enable_private_endpoint || var.deploy_using_private_endpoint ? google_container_cluster.primary.private_cluster_config[0].private_endpoint : google_container_cluster.primary.private_cluster_config[0].public_endpoint) : google_container_cluster.primary.endpoint
126-
cluster_peering_name = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? google_container_cluster.primary.private_cluster_config[0].peering_name : null
127-
cluster_endpoint_for_nodes = google_container_cluster.primary.private_cluster_config[0].master_ipv4_cidr_block
125+
cluster_endpoint = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? (var.enable_private_endpoint || var.deploy_using_private_endpoint ? google_container_cluster.primary.private_cluster_config[0].private_endpoint : google_container_cluster.primary.private_cluster_config[0].public_endpoint) : google_container_cluster.primary.endpoint
126+
cluster_peering_name = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? google_container_cluster.primary.private_cluster_config[0].peering_name : null
127+
cluster_endpoint_for_nodes = (var.enable_private_nodes && length(google_container_cluster.primary.private_cluster_config) > 0) ? (
128+
var.private_endpoint_subnetwork != null ?
129+
data.google_compute_subnetwork.private_endpoint_subnetwork[0].ip_cidr_range :
130+
var.master_ipv4_cidr_block != null ?
131+
google_container_cluster.primary.private_cluster_config[0].master_ipv4_cidr_block :
132+
local.cluster_subnet_cidr
133+
) : local.cluster_subnet_cidr
128134

129135
cluster_output_master_auth = concat(google_container_cluster.primary[*].master_auth, [])
130136
cluster_output_master_version = google_container_cluster.primary.master_version

modules/beta-private-cluster/networks.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ data "google_compute_subnetwork" "gke_subnetwork" {
2424
region = local.region
2525
project = local.network_project_id
2626
}
27+
28+
data "google_compute_subnetwork" "private_endpoint_subnetwork" {
29+
provider = google
30+
31+
count = var.private_endpoint_subnetwork != null ? 1 : 0
32+
name = var.private_endpoint_subnetwork
33+
region = local.region
34+
project = local.network_project_id
35+
}

modules/beta-public-cluster-update-variant/networks.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ data "google_compute_subnetwork" "gke_subnetwork" {
2424
region = local.region
2525
project = local.network_project_id
2626
}
27+

0 commit comments

Comments
 (0)