Skip to content

Commit

Permalink
Merge pull request #132 from marko7460/fix/empty-zone-list
Browse files Browse the repository at this point in the history
Fix/empty zone list
  • Loading branch information
aaron-lane committed Apr 4, 2019
2 parents aaa48de + e101f7b commit 00532b2
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 29 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ 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
Expand Down Expand Up @@ -72,6 +74,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
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion autogen/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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/", "")}"
Expand Down
2 changes: 1 addition & 1 deletion autogen/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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/", "")}"
Expand Down
8 changes: 4 additions & 4 deletions autogen/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion build/docker/kitchen_terraform/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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/", "")}"
Expand Down
2 changes: 1 addition & 1 deletion cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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/", "")}"
Expand Down
15 changes: 7 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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}"
}
2 changes: 1 addition & 1 deletion modules/private-cluster/cluster_regional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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/", "")}"
Expand Down
2 changes: 1 addition & 1 deletion modules/private-cluster/cluster_zonal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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/", "")}"
Expand Down
15 changes: 7 additions & 8 deletions modules/private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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}"
}

0 comments on commit 00532b2

Please sign in to comment.