diff --git a/modules/postgresql/README.md b/modules/postgresql/README.md index 11bc5066..b4b310ae 100644 --- a/modules/postgresql/README.md +++ b/modules/postgresql/README.md @@ -168,6 +168,7 @@ module "pg" { | read\_replica\_name\_suffix | The optional suffix to add to the read instance name | `string` | `""` | no | | read\_replicas | List of read replicas to create. Encryption key is required for replica in different region. For replica in same region as master set encryption\_key\_name = null |
list(object({
name = string
name_override = optional(string)
tier = optional(string)
edition = optional(string)
availability_type = optional(string)
zone = optional(string)
disk_type = optional(string)
disk_autoresize = optional(bool)
disk_autoresize_limit = optional(number)
disk_size = optional(string)
user_labels = map(string)
database_flags = optional(list(object({
name = string
value = string
})), [])
insights_config = optional(object({
query_plans_per_minute = optional(number, 5)
query_string_length = optional(number, 1024)
record_application_tags = optional(bool, false)
record_client_address = optional(bool, false)
}), null)
ip_configuration = object({
authorized_networks = optional(list(map(string)), [])
ipv4_enabled = optional(bool)
private_network = optional(string)
ssl_mode = optional(string)
allocated_ip_range = optional(string)
enable_private_path_for_google_cloud_services = optional(bool, false)
psc_enabled = optional(bool, false)
psc_allowed_consumer_projects = optional(list(string), [])
})
encryption_key_name = optional(string)
data_cache_enabled = optional(bool)
})) | `[]` | 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 | Initial root password during creation | `string` | `null` | no |
| secondary\_zone | The preferred zone for the replica instance, it should be something like: `us-central1-a`, `us-east1-c`. | `string` | `null` | no |
| tier | The tier for the Cloud SQL instance, for ADC its defualt value will be db-perf-optimized-N-8 which is tier value for edtion ENTERPRISE\_PLUS, if user wants to change the edition, he should chose compatible tier. | `string` | `"db-f1-micro"` | no |
diff --git a/modules/postgresql/main.tf b/modules/postgresql/main.tf
index a8284879..f44f7198 100644
--- a/modules/postgresql/main.tf
+++ b/modules/postgresql/main.tf
@@ -85,6 +85,7 @@ resource "google_sql_database_instance" "default" {
connector_enforcement = local.connector_enforcement
enable_google_ml_integration = var.enable_google_ml_integration
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]
diff --git a/modules/postgresql/variables.tf b/modules/postgresql/variables.tf
index 6596b0e8..3769abe2 100644
--- a/modules/postgresql/variables.tf
+++ b/modules/postgresql/variables.tf
@@ -477,3 +477,9 @@ variable "use_autokey" {
type = bool
default = false
}
+
+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
+}