From b007971f5e00580781bc8760112421f9e89ce742 Mon Sep 17 00:00:00 2001 From: Morgante Pell Date: Thu, 10 Jan 2019 09:59:04 -0500 Subject: [PATCH 1/6] Attempt fix for #63 --- main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index ca2ae78efd..2a6e38fb03 100644 --- a/main.tf +++ b/main.tf @@ -55,12 +55,12 @@ locals { zonal = "${var.region}" } - cluster_type_output_regional_zones = "${concat(google_container_cluster.primary.*.additional_zones, list(list()))}" - cluster_type_output_zonal_zones = "${concat(slice(var.zones,1,length(var.zones)), list(list()))}" + cluster_type_output_regional_zones = "${concat(google_container_cluster.primary.*.additional_zones, list("")}" + cluster_type_output_zonal_zones = "${concat(slice(var.zones, 1, length(var.zones)), list(""))}" cluster_type_output_zones = { regional = "${local.cluster_type_output_regional_zones[0]}" - zonal = "${concat(google_container_cluster.zonal_primary.*.zone, local.cluster_type_output_zonal_zones[0])}" + zonal = "${concat(google_container_cluster.zonal_primary.*.zone, local.cluster_type_output_zonal_zones)}" } cluster_type_output_endpoint = { From 46748af3a970c82b6a06db4cf8ddf96a62dcb88a Mon Sep 17 00:00:00 2001 From: Morgante Pell Date: Thu, 10 Jan 2019 10:31:07 -0500 Subject: [PATCH 2/6] Fix trailing ) issue --- main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 2a6e38fb03..1435d2606a 100644 --- a/main.tf +++ b/main.tf @@ -55,7 +55,7 @@ locals { zonal = "${var.region}" } - cluster_type_output_regional_zones = "${concat(google_container_cluster.primary.*.additional_zones, list("")}" + cluster_type_output_regional_zones = "${concat(google_container_cluster.primary.*.additional_zones, list(""))}" cluster_type_output_zonal_zones = "${concat(slice(var.zones, 1, length(var.zones)), list(""))}" cluster_type_output_zones = { From dc6c123a46ba7cd78a0d1373cc0c2d5606ac4dbd Mon Sep 17 00:00:00 2001 From: Aaron Lane Date: Thu, 10 Jan 2019 15:19:17 -0500 Subject: [PATCH 3/6] Update main.tf Co-Authored-By: morgante --- main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 1435d2606a..08d5728d00 100644 --- a/main.tf +++ b/main.tf @@ -59,7 +59,7 @@ locals { cluster_type_output_zonal_zones = "${concat(slice(var.zones, 1, length(var.zones)), list(""))}" cluster_type_output_zones = { - regional = "${local.cluster_type_output_regional_zones[0]}" + regional = "${local.cluster_type_output_regional_zones}" zonal = "${concat(google_container_cluster.zonal_primary.*.zone, local.cluster_type_output_zonal_zones)}" } From 1f6e0bb477cbdd012d1d863b5bb3b59c00e2c3d3 Mon Sep 17 00:00:00 2001 From: Marko Vlahovic Date: Wed, 3 Apr 2019 10:34:25 -0700 Subject: [PATCH 4/6] Updating PR with latest changes --- Makefile | 4 ++-- build/docker/kitchen_terraform/Dockerfile | 2 +- cluster_regional.tf | 4 ++-- cluster_zonal.tf | 4 ++-- main.tf | 6 +++--- modules/private-cluster/cluster_regional.tf | 2 +- modules/private-cluster/cluster_zonal.tf | 2 +- modules/private-cluster/main.tf | 8 ++++---- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 2c26d095fd..a599908763 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,10 @@ SHELL := /usr/bin/env bash # Docker build config variables CREDENTIALS_PATH ?= /cft/workdir/credentials.json DOCKER_ORG := gcr.io/cloud-foundation-cicd -DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 0.11.10_216.0.0_1.19.1_0.1.10 +DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 1.0.0 DOCKER_REPO_BASE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform:${DOCKER_TAG_BASE_KITCHEN_TERRAFORM} DOCKER_TAG_KITCHEN_TERRAFORM ?= ${DOCKER_TAG_BASE_KITCHEN_TERRAFORM} -DOCKER_IMAGE_KITCHEN_TERRAFORM := cft/kitchen-terraform_terraform-google-kubernetes-engine +DOCKER_IMAGE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform_terraform-google-kubernetes-engine # All is the first target in the file so it will get picked up when you just run 'make' on its own .PHONY: all diff --git a/build/docker/kitchen_terraform/Dockerfile b/build/docker/kitchen_terraform/Dockerfile index 7be34ac19b..1cbddf7e7a 100644 --- a/build/docker/kitchen_terraform/Dockerfile +++ b/build/docker/kitchen_terraform/Dockerfile @@ -18,7 +18,7 @@ ARG BASE_IMAGE FROM $BASE_IMAGE RUN apk add --no-cache \ - ca-certificates=20171114-r3 + ca-certificates=20190108-r0 ADD https://storage.googleapis.com/kubernetes-release/release/v1.12.2/bin/linux/amd64/kubectl /usr/local/bin/kubectl RUN chmod +x /usr/local/bin/kubectl diff --git a/cluster_regional.tf b/cluster_regional.tf index f31877961a..15d0267570 100644 --- a/cluster_regional.tf +++ b/cluster_regional.tf @@ -26,8 +26,8 @@ resource "google_container_cluster" "primary" { description = "${var.description}" project = "${var.project_id}" - region = "${var.region}" - additional_zones = ["${coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result))}"] + region = "${var.region}" + node_locations = ["${coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result))}"] network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}" subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}" diff --git a/cluster_zonal.tf b/cluster_zonal.tf index aa26cc4fc4..287424ed98 100644 --- a/cluster_zonal.tf +++ b/cluster_zonal.tf @@ -26,8 +26,8 @@ resource "google_container_cluster" "zonal_primary" { description = "${var.description}" project = "${var.project_id}" - zone = "${var.zones[0]}" - additional_zones = ["${slice(var.zones,1,length(var.zones))}"] + zone = "${var.zones[0]}" + node_locations = ["${slice(var.zones,1,length(var.zones))}"] network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}" subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}" diff --git a/main.tf b/main.tf index 08d5728d00..e96d301c43 100644 --- a/main.tf +++ b/main.tf @@ -55,11 +55,11 @@ locals { zonal = "${var.region}" } - cluster_type_output_regional_zones = "${concat(google_container_cluster.primary.*.additional_zones, list(""))}" - cluster_type_output_zonal_zones = "${concat(slice(var.zones, 1, length(var.zones)), list(""))}" + cluster_type_output_regional_zones = "${flatten(google_container_cluster.primary.*.node_locations)}" + cluster_type_output_zonal_zones = "${slice(var.zones, 1, length(var.zones))}" cluster_type_output_zones = { - regional = "${local.cluster_type_output_regional_zones}" + regional = "${local.cluster_type_output_regional_zones}" zonal = "${concat(google_container_cluster.zonal_primary.*.zone, local.cluster_type_output_zonal_zones)}" } diff --git a/modules/private-cluster/cluster_regional.tf b/modules/private-cluster/cluster_regional.tf index 53a3e2804b..a38b5c4cdd 100644 --- a/modules/private-cluster/cluster_regional.tf +++ b/modules/private-cluster/cluster_regional.tf @@ -27,7 +27,7 @@ resource "google_container_cluster" "primary" { project = "${var.project_id}" region = "${var.region}" - additional_zones = ["${coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result))}"] + node_locations = ["${coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result))}"] network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}" subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}" diff --git a/modules/private-cluster/cluster_zonal.tf b/modules/private-cluster/cluster_zonal.tf index 05f2f0932c..538f16565e 100644 --- a/modules/private-cluster/cluster_zonal.tf +++ b/modules/private-cluster/cluster_zonal.tf @@ -27,7 +27,7 @@ resource "google_container_cluster" "zonal_primary" { project = "${var.project_id}" zone = "${var.zones[0]}" - additional_zones = ["${slice(var.zones,1,length(var.zones))}"] + node_locations = ["${slice(var.zones,1,length(var.zones))}"] network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}" subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}" diff --git a/modules/private-cluster/main.tf b/modules/private-cluster/main.tf index 3e93de103c..7d38486404 100644 --- a/modules/private-cluster/main.tf +++ b/modules/private-cluster/main.tf @@ -55,12 +55,12 @@ locals { zonal = "${var.region}" } - cluster_type_output_regional_zones = "${concat(google_container_cluster.primary.*.additional_zones, list(list()))}" - cluster_type_output_zonal_zones = "${concat(slice(var.zones,1,length(var.zones)), list(list()))}" + cluster_type_output_regional_zones = "${flatten(google_container_cluster.primary.*.node_locations)}" + cluster_type_output_zonal_zones = "${slice(var.zones, 1, length(var.zones))}" cluster_type_output_zones = { - regional = "${local.cluster_type_output_regional_zones[0]}" - zonal = "${concat(google_container_cluster.zonal_primary.*.zone, local.cluster_type_output_zonal_zones[0])}" + regional = "${local.cluster_type_output_regional_zones}" + zonal = "${concat(google_container_cluster.zonal_primary.*.zone, local.cluster_type_output_zonal_zones)}" } cluster_type_output_endpoint = { From 79b1268fd699b02942290e792aa5f12049d56331 Mon Sep 17 00:00:00 2001 From: Marko Vlahovic Date: Thu, 4 Apr 2019 08:50:27 -0700 Subject: [PATCH 5/6] Updating code using autogen --- CHANGELOG.md | 2 ++ autogen/cluster_regional.tf | 2 +- autogen/cluster_zonal.tf | 2 +- autogen/main.tf | 8 ++++---- cluster_regional.tf | 4 ++-- cluster_zonal.tf | 4 ++-- main.tf | 7 +++---- modules/private-cluster/main.tf | 7 +++---- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92a7190bf8..72f9768cd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Extending the adopted spec, each change should have a link to its corresponding ## [v1.0.0] - 2019-03-25 ### Added +* Fix empty zone list. [#132] * Allow creation of service accounts. [#80] * Add support for private clusters via submodule. [#69] * Add `remove_default_node_pool` set to `false` by default. Fixes [#15]. [#55] @@ -72,6 +73,7 @@ Extending the adopted spec, each change should have a link to its corresponding [#42]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/issues/42 [#15]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/issues/15 +[#132]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/132 [#109]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/109 [#108]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/108 [#106]: https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/pull/106 diff --git a/autogen/cluster_regional.tf b/autogen/cluster_regional.tf index d4b17b8cf0..1876f06cee 100644 --- a/autogen/cluster_regional.tf +++ b/autogen/cluster_regional.tf @@ -27,7 +27,7 @@ resource "google_container_cluster" "primary" { project = "${var.project_id}" region = "${var.region}" - additional_zones = ["${coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result))}"] + node_locations = ["${coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result))}"] network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}" subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}" diff --git a/autogen/cluster_zonal.tf b/autogen/cluster_zonal.tf index da99b4b43f..1933bd2ee2 100644 --- a/autogen/cluster_zonal.tf +++ b/autogen/cluster_zonal.tf @@ -27,7 +27,7 @@ resource "google_container_cluster" "zonal_primary" { project = "${var.project_id}" zone = "${var.zones[0]}" - additional_zones = ["${slice(var.zones,1,length(var.zones))}"] + node_locations = ["${slice(var.zones,1,length(var.zones))}"] network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}" subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}" diff --git a/autogen/main.tf b/autogen/main.tf index c803eedc4f..9f23ab70e9 100644 --- a/autogen/main.tf +++ b/autogen/main.tf @@ -55,12 +55,12 @@ locals { zonal = "${var.region}" } - cluster_type_output_regional_zones = "${concat(google_container_cluster.primary.*.additional_zones, list(list()))}" - cluster_type_output_zonal_zones = "${concat(slice(var.zones,1,length(var.zones)), list(list()))}" + cluster_type_output_regional_zones = "${flatten(google_container_cluster.primary.*.node_locations)}" + cluster_type_output_zonal_zones = "${slice(var.zones, 1, length(var.zones))}" cluster_type_output_zones = { - regional = "${local.cluster_type_output_regional_zones[0]}" - zonal = "${concat(google_container_cluster.zonal_primary.*.zone, local.cluster_type_output_zonal_zones[0])}" + regional = "${local.cluster_type_output_regional_zones}" + zonal = "${concat(google_container_cluster.zonal_primary.*.zone, local.cluster_type_output_zonal_zones)}" } cluster_type_output_endpoint = { diff --git a/cluster_regional.tf b/cluster_regional.tf index 15d0267570..db99e3e605 100644 --- a/cluster_regional.tf +++ b/cluster_regional.tf @@ -26,8 +26,8 @@ resource "google_container_cluster" "primary" { description = "${var.description}" project = "${var.project_id}" - region = "${var.region}" - node_locations = ["${coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result))}"] + region = "${var.region}" + node_locations = ["${coalescelist(compact(var.zones), sort(random_shuffle.available_zones.result))}"] network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}" subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}" diff --git a/cluster_zonal.tf b/cluster_zonal.tf index 287424ed98..4a61363d93 100644 --- a/cluster_zonal.tf +++ b/cluster_zonal.tf @@ -26,8 +26,8 @@ resource "google_container_cluster" "zonal_primary" { description = "${var.description}" project = "${var.project_id}" - zone = "${var.zones[0]}" - node_locations = ["${slice(var.zones,1,length(var.zones))}"] + zone = "${var.zones[0]}" + node_locations = ["${slice(var.zones,1,length(var.zones))}"] network = "${replace(data.google_compute_network.gke_network.self_link, "https://www.googleapis.com/compute/v1/", "")}" subnetwork = "${replace(data.google_compute_subnetwork.gke_subnetwork.self_link, "https://www.googleapis.com/compute/v1/", "")}" diff --git a/main.tf b/main.tf index e96d301c43..6a519dfff1 100644 --- a/main.tf +++ b/main.tf @@ -161,7 +161,6 @@ data "google_container_engine_versions" "zone" { // // data.google_container_engine_versions.zone: Cannot determine zone: set in this resource, or set provider-level zone. // - zone = "${var.zones[0] == "" ? data.google_compute_zones.available.names[0] : var.zones[0]}" - - project = "${var.project_id}" -} + zone = "${var.zones[0] == "" ? data.google_compute_zones.available.names[0] : var.zones[0]}" + project = "${var.project_id}" +} \ No newline at end of file diff --git a/modules/private-cluster/main.tf b/modules/private-cluster/main.tf index 7d38486404..f15ff057c3 100644 --- a/modules/private-cluster/main.tf +++ b/modules/private-cluster/main.tf @@ -161,7 +161,6 @@ data "google_container_engine_versions" "zone" { // // data.google_container_engine_versions.zone: Cannot determine zone: set in this resource, or set provider-level zone. // - zone = "${var.zones[0] == "" ? data.google_compute_zones.available.names[0] : var.zones[0]}" - - project = "${var.project_id}" -} + zone = "${var.zones[0] == "" ? data.google_compute_zones.available.names[0] : var.zones[0]}" + project = "${var.project_id}" +} \ No newline at end of file From e101f7b3f6db3fe7a6121d0f4b4ac5fb21f9dc62 Mon Sep 17 00:00:00 2001 From: Marko Vlahovic Date: Thu, 4 Apr 2019 14:00:47 -0700 Subject: [PATCH 6/6] Fixing CHANGELOG entry --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72f9768cd0..faee181173 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 Extending the adopted spec, each change should have a link to its corresponding pull request appended. ## [Unreleased] +### Fixed +* Fix empty zone list. [#132] ## [v1.0.0] - 2019-03-25 ### Added -* Fix empty zone list. [#132] * Allow creation of service accounts. [#80] * Add support for private clusters via submodule. [#69] * Add `remove_default_node_pool` set to `false` by default. Fixes [#15]. [#55]