Skip to content

Commit eb9b52f

Browse files
b-nimrannayer
andauthored
feat: Support retain_backups_on_delete for postgres (#737)
Co-authored-by: Imran Nayer <[email protected]>
1 parent d0b31dd commit eb9b52f

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

modules/postgresql/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ module "pg" {
168168
| read\_replica\_name\_suffix | The optional suffix to add to the read instance name | `string` | `""` | no |
169169
| 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 | <pre>list(object({<br> name = string<br> name_override = optional(string)<br> tier = optional(string)<br> edition = optional(string)<br> availability_type = optional(string)<br> zone = optional(string)<br> disk_type = optional(string)<br> disk_autoresize = optional(bool)<br> disk_autoresize_limit = optional(number)<br> disk_size = optional(string)<br> user_labels = map(string)<br> database_flags = optional(list(object({<br> name = string<br> value = string<br> })), [])<br> insights_config = optional(object({<br> query_plans_per_minute = optional(number, 5)<br> query_string_length = optional(number, 1024)<br> record_application_tags = optional(bool, false)<br> record_client_address = optional(bool, false)<br> }), null)<br> ip_configuration = object({<br> authorized_networks = optional(list(map(string)), [])<br> ipv4_enabled = optional(bool)<br> private_network = optional(string)<br> ssl_mode = optional(string)<br> allocated_ip_range = optional(string)<br> enable_private_path_for_google_cloud_services = optional(bool, false)<br> psc_enabled = optional(bool, false)<br> psc_allowed_consumer_projects = optional(list(string), [])<br> })<br> encryption_key_name = optional(string)<br> data_cache_enabled = optional(bool)<br> }))</pre> | `[]` | no |
170170
| region | The region of the Cloud SQL resources | `string` | `"us-central1"` | no |
171+
| 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 |
171172
| root\_password | Initial root password during creation | `string` | `null` | no |
172173
| secondary\_zone | The preferred zone for the replica instance, it should be something like: `us-central1-a`, `us-east1-c`. | `string` | `null` | no |
173174
| 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 |

modules/postgresql/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ resource "google_sql_database_instance" "default" {
8585
connector_enforcement = local.connector_enforcement
8686
enable_google_ml_integration = var.enable_google_ml_integration
8787
enable_dataplex_integration = var.enable_dataplex_integration
88+
retain_backups_on_delete = var.retain_backups_on_delete
8889

8990
dynamic "backup_configuration" {
9091
for_each = local.is_secondary_instance ? [] : [var.backup_configuration]

modules/postgresql/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,9 @@ variable "use_autokey" {
477477
type = bool
478478
default = false
479479
}
480+
481+
variable "retain_backups_on_delete" {
482+
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."
483+
type = bool
484+
default = false
485+
}

0 commit comments

Comments
 (0)