cloudsql maintenance window day made optional (#3693)
* - Mark maintenance_window.day as optional\n- Update validation logic to allow null values\n- Keep existing range checks when day is provided * - Mark maintenance_window.day as optional\n- Update validation logic to allow null values\n- Keep existing range checks when day is provided * updated the Readme * refactor maintenance config day validation for cloud sql instance --------- Co-authored-by: Julio Castillo <jccb@google.com>
This commit is contained in:
@@ -154,7 +154,7 @@ variable "maintenance_config" {
|
||||
description = "Set maintenance window configuration and maintenance deny period (up to 90 days). Date format: 'yyyy-mm-dd'."
|
||||
type = object({
|
||||
maintenance_window = optional(object({
|
||||
day = number
|
||||
day = optional(number)
|
||||
hour = number
|
||||
update_track = optional(string, null)
|
||||
}), null)
|
||||
@@ -169,8 +169,10 @@ variable "maintenance_config" {
|
||||
condition = (
|
||||
try(var.maintenance_config.maintenance_window, null) == null ? true : (
|
||||
# Maintenance window day validation below
|
||||
var.maintenance_config.maintenance_window.day >= 1 &&
|
||||
var.maintenance_config.maintenance_window.day <= 7 &&
|
||||
var.maintenance_config.maintenance_window.day == null || (
|
||||
var.maintenance_config.maintenance_window.day >= 1 &&
|
||||
var.maintenance_config.maintenance_window.day <= 7
|
||||
) &&
|
||||
# Maintenance window hour validation below
|
||||
var.maintenance_config.maintenance_window.hour >= 0 &&
|
||||
var.maintenance_config.maintenance_window.hour <= 23 &&
|
||||
@@ -179,7 +181,7 @@ variable "maintenance_config" {
|
||||
contains(["canary", "stable"], var.maintenance_config.maintenance_window.update_track)
|
||||
)
|
||||
)
|
||||
error_message = "Maintenance window day must be between 1 and 7, maintenance window hour must be between 0 and 23 and maintenance window update_track must be 'stable' or 'canary'."
|
||||
error_message = "Maintenance window day must be between 1 and 7 or null, maintenance window hour must be between 0 and 23 and maintenance window update_track must be 'stable' or 'canary'."
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user