From e74e0caced62edcb6c351e3f79eb4cb9f300d7bb Mon Sep 17 00:00:00 2001 From: Anthony Hausman Date: Fri, 10 Nov 2023 09:18:32 +0100 Subject: [PATCH] feat(gke-cluster-standard): Fix validation condition for `cluster_autoscaling` --- modules/gke-cluster-standard/README.md | 2 +- modules/gke-cluster-standard/variables.tf | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/gke-cluster-standard/README.md b/modules/gke-cluster-standard/README.md index 88f52ac78d..e895b4819c 100644 --- a/modules/gke-cluster-standard/README.md +++ b/modules/gke-cluster-standard/README.md @@ -315,7 +315,7 @@ module "cluster-1" { | [project_id](variables.tf#L315) | Cluster project id. | string | ✓ | | | [vpc_config](variables.tf#L338) | VPC-level configuration. | object({…}) | ✓ | | | [backup_configs](variables.tf#L17) | Configuration for Backup for GKE. | object({…}) | | {} | -| [cluster_autoscaling](variables.tf#L38) | Enable and configure limits for Node Auto-Provisioning with Cluster Autoscaler. | object({…}) | | {} | +| [cluster_autoscaling](variables.tf#L38) | Enable and configure limits for Node Auto-Provisioning with Cluster Autoscaler. | object({…}) | | null | | [deletion_protection](variables.tf#L83) | Whether or not to allow Terraform to destroy the cluster. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the cluster will fail. | bool | | true | | [description](variables.tf#L90) | Cluster description. | string | | null | | [enable_addons](variables.tf#L96) | Addons enabled in the cluster (true means enabled). | object({…}) | | {…} | diff --git a/modules/gke-cluster-standard/variables.tf b/modules/gke-cluster-standard/variables.tf index f44fc4aa41..eebd595a05 100644 --- a/modules/gke-cluster-standard/variables.tf +++ b/modules/gke-cluster-standard/variables.tf @@ -69,13 +69,13 @@ variable "cluster_autoscaling" { max = number }))) }) - default = {} + default = null validation { - condition = contains(["BALANCED", "OPTIMIZE_UTILIZATION"], var.cluster_autoscaling.autoscaling_profile) + condition = (var.cluster_autoscaling == null ? true : contains(["BALANCED", "OPTIMIZE_UTILIZATION"], var.cluster_autoscaling.autoscaling_profile)) error_message = "Invalid autoscaling_profile." } validation { - condition = contains(["pd-standard", "pd-ssd", "pd-balanced"], var.cluster_autoscaling.auto_provisioning_defaults.disk_type) + condition = (var.cluster_autoscaling == null ? true : contains(["pd-standard", "pd-ssd", "pd-balanced"], var.cluster_autoscaling.auto_provisioning_defaults.disk_type)) error_message = "Invalid disk_type." } }