From 2e644a3333af5c6888d537503d64120467aa80df Mon Sep 17 00:00:00 2001 From: Ludovico Magnocavallo Date: Sun, 16 Aug 2020 20:36:52 +0200 Subject: [PATCH] streamline gke module peering project id --- modules/gke-cluster/README.md | 2 +- modules/gke-cluster/main.tf | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/gke-cluster/README.md b/modules/gke-cluster/README.md index 98d8aaff..d0293f06 100644 --- a/modules/gke-cluster/README.md +++ b/modules/gke-cluster/README.md @@ -58,7 +58,7 @@ module "cluster-1" { | *min_master_version* | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | | *monitoring_service* | Monitoring service (disable with an empty string). | string | | monitoring.googleapis.com/kubernetes | | *node_locations* | Zones in which the cluster's nodes are located. | list(string) | | [] | -| *peering_config* | Configure peering with the master VPC for private clusters. | object({...}) | | null | +| *peering_config* | Configure peering with the master VPC for private clusters. | object({...}) | | null | | *pod_security_policy* | Enable the PodSecurityPolicy feature. | bool | | null | | *private_cluster_config* | Enable and configure private cluster, private nodes must be true if used. | object({...}) | | null | | *release_channel* | Release channel for GKE upgrades. | string | | null | diff --git a/modules/gke-cluster/main.tf b/modules/gke-cluster/main.tf index 29e5a8ea..c17b1ada 100644 --- a/modules/gke-cluster/main.tf +++ b/modules/gke-cluster/main.tf @@ -22,7 +22,11 @@ locals { google_container_cluster.cluster.private_cluster_config.0.peering_name, null ) - peering_project_id = try(var.peering_config.project_id, "") == "" ? var.project_id : (var.peering_config.project_id == "" ? var.project_id : var.peering_config.project_id) + peering_project_id = ( + try(var.peering_config.project_id, null) == null + ? var.project_id + : var.peering_config.project_id + ) } resource "google_container_cluster" "cluster" {