Skip to content

Commit d0b31dd

Browse files
feat(TPG>6.31)!: Support retain_backups_on_delete for mysql, safer_mysql (#735)
Co-authored-by: Imran Nayer <[email protected]>
1 parent 15e8be8 commit d0b31dd

File tree

8 files changed

+21
-4
lines changed

8 files changed

+21
-4
lines changed

modules/mysql/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ module "mysql-db" {
9797
| 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 = list(object({<br> name = string<br> value = string<br> }))<br> backup_configuration = optional(object({<br> binary_log_enabled = bool<br> transaction_log_retention_days = string<br> }))<br> insights_config = optional(object({<br> query_plans_per_minute = number<br> query_string_length = number<br> record_application_tags = bool<br> record_client_address = bool<br> }))<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 |
9898
| region | The region of the Cloud SQL resources | `string` | `"us-central1"` | no |
9999
| replica\_database\_version | The read replica database version to use. This var should only be used during a database update. The update sequence 1. read-replica 2. master, setting this to an updated version will cause the replica to update, then you may update the master with the var database\_version and remove this field after update is complete | `string` | `""` | no |
100+
| 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 |
100101
| root\_password | MySQL password for the root user. | `string` | `null` | no |
101102
| secondary\_zone | The preferred zone for the secondary/failover instance, it should be something like: `us-central1-a`, `us-east1-c`. | `string` | `null` | no |
102103
| tier | The tier for the master 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-n1-standard-1"` | no |

modules/mysql/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ resource "google_sql_database_instance" "default" {
8080
connector_enforcement = local.connector_enforcement
8181
enable_google_ml_integration = var.enable_google_ml_integration
8282
enable_dataplex_integration = var.enable_dataplex_integration
83+
retain_backups_on_delete = var.retain_backups_on_delete
8384

8485
dynamic "backup_configuration" {
8586
for_each = [var.backup_configuration]

modules/mysql/variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,12 @@ variable "backup_configuration" {
314314
default = {}
315315
}
316316

317+
variable "retain_backups_on_delete" {
318+
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."
319+
type = bool
320+
default = false
321+
}
322+
317323
variable "insights_config" {
318324
description = "The insights_config settings for the database."
319325
type = object({
@@ -480,3 +486,4 @@ variable "database_integration_roles" {
480486
type = list(string)
481487
default = []
482488
}
489+

modules/mysql/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ terraform {
2727
}
2828
google = {
2929
source = "hashicorp/google"
30-
version = ">= 6.17, < 7"
30+
version = ">= 6.31, < 7"
3131
}
3232
google-beta = {
3333
source = "hashicorp/google-beta"
34-
version = ">= 6.17, < 7"
34+
version = ">= 6.31, < 7"
3535
}
3636
}
3737

modules/safer_mysql/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ module "safer-mysql-db" {
284284
| read\_replica\_name\_suffix | The optional suffix to add to the read instance name | `string` | `""` | no |
285285
| 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 = string<br> edition = string<br> availability_type = string<br> zone = string<br> disk_type = string<br> disk_autoresize = bool<br> disk_autoresize_limit = number<br> disk_size = string<br> user_labels = map(string)<br> database_flags = list(object({<br> name = string<br> value = string<br> }))<br> insights_config = optional(object({<br> query_plans_per_minute = number<br> query_string_length = number<br> record_application_tags = bool<br> record_client_address = bool<br> }))<br> ip_configuration = object({<br> authorized_networks = list(map(string))<br> ipv4_enabled = bool<br> private_network = string<br> allocated_ip_range = string<br> })<br> encryption_key_name = string<br> }))</pre> | `[]` | no |
286286
| region | The region of the Cloud SQL resources | `string` | n/a | yes |
287+
| 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` | `true` | no |
287288
| secondary\_zone | The preferred zone for the secondary/failover instance, it should be something like: `us-central1-a`, `us-east1-c`. | `string` | `null` | no |
288289
| tier | The tier for the master instance. | `string` | `"db-n1-standard-1"` | no |
289290
| update\_timeout | The optional timout that is applied to limit long database updates. | `string` | `"30m"` | no |

modules/safer_mysql/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ module "safer_mysql" {
5050

5151
user_labels = var.user_labels
5252

53-
backup_configuration = var.backup_configuration
53+
backup_configuration = var.backup_configuration
54+
retain_backups_on_delete = var.retain_backups_on_delete
5455

5556
insights_config = var.insights_config
5657

modules/safer_mysql/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ variable "backup_configuration" {
237237
}
238238
}
239239

240+
variable "retain_backups_on_delete" {
241+
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."
242+
type = bool
243+
default = true
244+
}
245+
240246
variable "assign_public_ip" {
241247
description = "Set to true if the master instance should also have a public IP (less secure)."
242248
type = bool

modules/safer_mysql/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ terraform {
2020

2121
google = {
2222
source = "hashicorp/google"
23-
version = ">= 6.17, < 7"
23+
version = ">= 6.31, < 7"
2424
}
2525
}
2626

0 commit comments

Comments
 (0)