From 265636dbf11f6d8e6c3c492af84c95b9d227fd5d Mon Sep 17 00:00:00 2001 From: Veronika Priesner Date: Thu, 21 Aug 2025 11:38:58 +0200 Subject: [PATCH] fix: add retain_backups_on_delete to mssql submodule --- modules/mssql/README.md | 1 + modules/mssql/main.tf | 1 + modules/mssql/variables.tf | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/modules/mssql/README.md b/modules/mssql/README.md index f2a47c53..99cac6ee 100644 --- a/modules/mssql/README.md +++ b/modules/mssql/README.md @@ -74,6 +74,7 @@ module "mssql" { | project\_id | The project ID to manage the Cloud SQL resources | `string` | n/a | yes | | random\_instance\_name | Sets random suffix at the end of the Cloud SQL resource name | `bool` | `false` | no | | region | The region of the Cloud SQL resources | `string` | `"us-central1"` | no | +| retain\_backups\_on\_delete | When this parameter is set to true, Cloud SQL retains backups of the instance even after the instance is deleted. The ON\_DEMAND backup will be retained until customer deletes the backup or the project. The AUTOMATED backup will be retained based on the backups retention setting. | `bool` | `false` | no | | root\_password | MSSERVER password for the root user. If not set, a random one will be generated and available in the root\_password output variable. | `string` | `""` | no | | secondary\_zone | The preferred zone for the read replica instance, it should be something like: `us-central1-a`, `us-east1-c`. | `string` | `null` | no | | sql\_server\_audit\_config | SQL server audit config settings. | `map(string)` | `{}` | no | diff --git a/modules/mssql/main.tf b/modules/mssql/main.tf index 40a556b2..c5756c6a 100644 --- a/modules/mssql/main.tf +++ b/modules/mssql/main.tf @@ -63,6 +63,7 @@ resource "google_sql_database_instance" "default" { deletion_protection_enabled = var.deletion_protection_enabled connector_enforcement = local.connector_enforcement enable_dataplex_integration = var.enable_dataplex_integration + retain_backups_on_delete = var.retain_backups_on_delete dynamic "backup_configuration" { for_each = !local.is_secondary_instance && var.backup_configuration.enabled ? [var.backup_configuration] : [] diff --git a/modules/mssql/variables.tf b/modules/mssql/variables.tf index d731f910..fb1ddf98 100644 --- a/modules/mssql/variables.tf +++ b/modules/mssql/variables.tf @@ -241,6 +241,12 @@ variable "backup_configuration" { } } +variable "retain_backups_on_delete" { + description = "When this parameter is set to true, Cloud SQL retains backups of the instance even after the instance is deleted. The ON_DEMAND backup will be retained until customer deletes the backup or the project. The AUTOMATED backup will be retained based on the backups retention setting." + type = bool + default = false +} + variable "db_name" { description = "The name of the default database to create" type = string