fix(cloudsql): always render backup_configuration block to allow disabling backups (#3780)

* fix(cloudsql): always render backup_configuration block to allow disabling backups

* refactor(cloudsql): use nullable backup_configuration variable for explicit don't-manage semantics

* fix(cloudsql): force point_in_time_recovery_enabled=false when backups disabled

* fix(cloudsql): guard binary_log_enabled and point_in_time_recovery_enabled when backups disabled

* formatting

---------

Co-authored-by: Ludovico Magnocavallo <ludomagno@google.com>
This commit is contained in:
Daniel Chan
2026-03-05 05:12:10 -05:00
committed by GitHub
parent da85eda9b7
commit 27b43b7c75
3 changed files with 58 additions and 57 deletions

View File

@@ -31,8 +31,8 @@ variable "availability_type" {
}
variable "backup_configuration" {
description = "Backup settings for primary instance. Will be automatically enabled if using MySQL with one or more replicas."
nullable = false
description = "Backup settings for primary instance. Set to null to leave existing GCP backup settings unmanaged. When set, all fields are managed by Terraform including disabling backups when enabled=false."
nullable = true
type = object({
enabled = optional(bool, false)
binary_log_enabled = optional(bool, false)
@@ -47,17 +47,7 @@ variable "backup_configuration" {
retention_days = optional(number, 7)
}))
})
default = {
enabled = false
binary_log_enabled = false
start_time = "23:00"
location = null
log_retention_days = 7
point_in_time_recovery_enabled = null
retention_count = 7
retain_backups_on_delete = null
final_backup = null
}
default = null
}
variable "collation" {