From 76aaec5cdc960380d1ddf94b2d55cb4c77af9ba7 Mon Sep 17 00:00:00 2001 From: Mikhail Nacharov <1246847+mnacharov@users.noreply.github.com> Date: Tue, 16 Dec 2025 10:49:30 +0100 Subject: [PATCH] fix: allow to set "Any window" value in option "Maintenance window" fixes #792 --- modules/mysql/main.tf | 2 +- modules/mysql/variables.tf | 4 ++-- modules/postgresql/main.tf | 2 +- modules/postgresql/variables.tf | 4 ++-- modules/safer_mysql/variables.tf | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/mysql/main.tf b/modules/mysql/main.tf index b1db8414..1e5e8ca0 100644 --- a/modules/mysql/main.tf +++ b/modules/mysql/main.tf @@ -215,7 +215,7 @@ resource "google_sql_database_instance" "default" { // Maintenance windows cannot be set for read replicas: https://cloud.google.com/sql/docs/mysql/instance-settings#maintenance-window-2ndgen dynamic "maintenance_window" { - for_each = var.master_instance_name != null ? [] : ["true"] + for_each = var.master_instance_name != null && var.maintenance_window_day != 0 ? [] : ["true"] content { day = var.maintenance_window_day diff --git a/modules/mysql/variables.tf b/modules/mysql/variables.tf index d005cc49..294a081b 100644 --- a/modules/mysql/variables.tf +++ b/modules/mysql/variables.tf @@ -257,9 +257,9 @@ variable "pricing_plan" { } variable "maintenance_window_day" { - description = "The day of week (1-7) for the master instance maintenance." + description = "The day of week (1-7) for the master instance maintenance. 0 means 'Any' (default)" type = number - default = 1 + default = 0 } variable "maintenance_window_hour" { diff --git a/modules/postgresql/main.tf b/modules/postgresql/main.tf index 1f82edc6..9ecffd8d 100644 --- a/modules/postgresql/main.tf +++ b/modules/postgresql/main.tf @@ -223,7 +223,7 @@ resource "google_sql_database_instance" "default" { } dynamic "maintenance_window" { - for_each = local.is_secondary_instance ? [] : ["maintenance_window"] + for_each = local.is_secondary_instance && var.maintenance_window_day != 0 ? [] : ["maintenance_window"] content { day = var.maintenance_window_day hour = var.maintenance_window_hour diff --git a/modules/postgresql/variables.tf b/modules/postgresql/variables.tf index 27a21eb7..61fb40ff 100644 --- a/modules/postgresql/variables.tf +++ b/modules/postgresql/variables.tf @@ -249,9 +249,9 @@ variable "pricing_plan" { } variable "maintenance_window_day" { - description = "The day of week (1-7) for the Cloud SQL instance maintenance." + description = "The day of week (1-7) for the Cloud SQL instance maintenance. 0 means 'Any' (default)" type = number - default = 1 + default = 0 } variable "maintenance_window_hour" { diff --git a/modules/safer_mysql/variables.tf b/modules/safer_mysql/variables.tf index d15498bc..bd663c3a 100644 --- a/modules/safer_mysql/variables.tf +++ b/modules/safer_mysql/variables.tf @@ -167,9 +167,9 @@ variable "pricing_plan" { } variable "maintenance_window_day" { - description = "The day of week (1-7) for the master instance maintenance." + description = "The day of week (1-7) for the master instance maintenance. 0 means 'Any' (default)" type = number - default = 1 + default = 0 } variable "maintenance_window_hour" {