Skip to content

Commit 1313afc

Browse files
committed
Fix out of bounds use of slice on zones
This appears to have changed from Terraform 0.11 which must have silently swallowed the out of bounds error.
1 parent 79d454f commit 1313afc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

autogen/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ locals {
4343
custom_kube_dns_config = length(keys(var.stub_domains)) > 0
4444
upstream_nameservers_config = length(var.upstream_nameservers) > 0
4545
network_project_id = var.network_project_id != "" ? var.network_project_id : var.project_id
46+
zone_count = length(var.zones)
4647

4748
cluster_type = var.regional ? "regional" : "zonal"
4849

@@ -84,7 +85,7 @@ locals {
8485
}
8586

8687
cluster_type_output_regional_zones = flatten(google_container_cluster.primary.*.node_locations)
87-
cluster_type_output_zonal_zones = slice(var.zones, 1, length(var.zones))
88+
cluster_type_output_zonal_zones = local.zone_count > 1 ? slice(var.zones, 1, local.zone_count) : []
8889

8990
cluster_type_output_zones = {
9091
regional = local.cluster_type_output_regional_zones
@@ -306,7 +307,7 @@ data "google_container_engine_versions" "zone" {
306307
//
307308
// data.google_container_engine_versions.zone: Cannot determine zone: set in this resource, or set provider-level zone.
308309
//
309-
zone = var.zones[0] == "" ? data.google_compute_zones.available.names[0] : var.zones[0]
310+
zone = local.zone_count == 0 ? data.google_compute_zones.available.names[0] : var.zones[0]
310311

311312
project = var.project_id
312313
}

0 commit comments

Comments
 (0)