From 3316fa89873f07fae3398b292820b5cb054879c8 Mon Sep 17 00:00:00 2001 From: Steve Jalim Date: Wed, 9 Sep 2026 09:40:39 +0100 Subject: [PATCH] feat(google_cloudsql_postgres): allow configuring backup start time Adds an optional backup_start_time variable (HH:MM, UTC) that maps to the backup_configuration.start_time argument on the primary instance. Defaults to null, matching prior behavior where Cloud SQL picks a random start time, so this is a no-op for existing callers. --- google_cloudsql_postgres/README.md | 1 + google_cloudsql_postgres/main.tf | 1 + google_cloudsql_postgres/variables.tf | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/google_cloudsql_postgres/README.md b/google_cloudsql_postgres/README.md index 86f63c95..f190eb86 100644 --- a/google_cloudsql_postgres/README.md +++ b/google_cloudsql_postgres/README.md @@ -104,6 +104,7 @@ module "postgres_database" { | [availability\_type](#input\_availability\_type) | high availability (REGIONAL) or single zone (ZONAL) | `string` | `"REGIONAL"` | no | | [backup\_configuration\_enabled](#input\_backup\_configuration\_enabled) | n/a | `bool` | `true` | no | | [backup\_configuration\_location](#input\_backup\_configuration\_location) | n/a | `string` | `"us"` | no | +| [backup\_start\_time](#input\_backup\_start\_time) | HH:MM format time (UTC) indicating when the daily backup window should start. If null, Google Cloud selects a random start time. | `string` | `null` | no | | [component](#input\_component) | A logical component of an application | `string` | `"db"` | no | | [connector\_enforcement](#input\_connector\_enforcement) | Enables the enforcement of Cloud SQL Auth Proxy or Cloud SQL connectors for all the connections. If enabled, all the direct connections are rejected. | `string` | `null` | no | | [custom\_database\_name](#input\_custom\_database\_name) | Use this field for custom database name. | `string` | `""` | no | diff --git a/google_cloudsql_postgres/main.tf b/google_cloudsql_postgres/main.tf index a2542362..71cc432a 100644 --- a/google_cloudsql_postgres/main.tf +++ b/google_cloudsql_postgres/main.tf @@ -58,6 +58,7 @@ resource "google_sql_database_instance" "primary" { enabled = var.backup_configuration_enabled point_in_time_recovery_enabled = var.point_in_time_recovery_enabled location = var.backup_configuration_location + start_time = var.backup_start_time backup_retention_settings { retained_backups = 30 diff --git a/google_cloudsql_postgres/variables.tf b/google_cloudsql_postgres/variables.tf index 4381b220..f4782c9d 100644 --- a/google_cloudsql_postgres/variables.tf +++ b/google_cloudsql_postgres/variables.tf @@ -32,6 +32,12 @@ variable "backup_configuration_location" { type = string } +variable "backup_start_time" { + default = null + description = "HH:MM format time (UTC) indicating when the daily backup window should start. If null, Google Cloud selects a random start time." + type = string +} + variable "component" { default = "db" description = "A logical component of an application"