diff --git a/modules/mysql/README.md b/modules/mysql/README.md index c1422e23..371926e0 100644 --- a/modules/mysql/README.md +++ b/modules/mysql/README.md @@ -97,6 +97,7 @@ module "mysql-db" { | 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 = list(object({
name = string
value = string
}))
backup_configuration = optional(object({
binary_log_enabled = bool
transaction_log_retention_days = string
}))
insights_config = optional(object({
query_plans_per_minute = number
query_string_length = number
record_application_tags = bool
record_client_address = bool
}))
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 | | 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 | +| 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 | MySQL password for the root user. | `string` | `null` | no | | secondary\_zone | The preferred zone for the secondary/failover instance, it should be something like: `us-central1-a`, `us-east1-c`. | `string` | `null` | no | | 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 | diff --git a/modules/mysql/main.tf b/modules/mysql/main.tf index bd14dbd8..57158479 100644 --- a/modules/mysql/main.tf +++ b/modules/mysql/main.tf @@ -80,6 +80,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 = [var.backup_configuration] diff --git a/modules/mysql/variables.tf b/modules/mysql/variables.tf index 2be0451e..db742727 100644 --- a/modules/mysql/variables.tf +++ b/modules/mysql/variables.tf @@ -314,6 +314,12 @@ variable "backup_configuration" { default = {} } +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 "insights_config" { description = "The insights_config settings for the database." type = object({ @@ -480,3 +486,4 @@ variable "database_integration_roles" { type = list(string) default = [] } + diff --git a/modules/mysql/versions.tf b/modules/mysql/versions.tf index ab1c32bd..fd61ed03 100644 --- a/modules/mysql/versions.tf +++ b/modules/mysql/versions.tf @@ -27,11 +27,11 @@ terraform { } google = { source = "hashicorp/google" - version = ">= 6.17, < 7" + version = ">= 6.31, < 7" } google-beta = { source = "hashicorp/google-beta" - version = ">= 6.17, < 7" + version = ">= 6.31, < 7" } } diff --git a/modules/safer_mysql/README.md b/modules/safer_mysql/README.md index a64f2486..c0b9de04 100644 --- a/modules/safer_mysql/README.md +++ b/modules/safer_mysql/README.md @@ -284,6 +284,7 @@ module "safer-mysql-db" { | 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 = string
edition = string
availability_type = string
zone = string
disk_type = string
disk_autoresize = bool
disk_autoresize_limit = number
disk_size = string
user_labels = map(string)
database_flags = list(object({
name = string
value = string
}))
insights_config = optional(object({
query_plans_per_minute = number
query_string_length = number
record_application_tags = bool
record_client_address = bool
}))
ip_configuration = object({
authorized_networks = list(map(string))
ipv4_enabled = bool
private_network = string
allocated_ip_range = string
})
encryption_key_name = string
}))
| `[]` | no | | region | The region of the Cloud SQL resources | `string` | n/a | yes | +| 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 | | secondary\_zone | The preferred zone for the secondary/failover instance, it should be something like: `us-central1-a`, `us-east1-c`. | `string` | `null` | no | | tier | The tier for the master instance. | `string` | `"db-n1-standard-1"` | no | | update\_timeout | The optional timout that is applied to limit long database updates. | `string` | `"30m"` | no | diff --git a/modules/safer_mysql/main.tf b/modules/safer_mysql/main.tf index d3e784cf..72398da6 100644 --- a/modules/safer_mysql/main.tf +++ b/modules/safer_mysql/main.tf @@ -50,7 +50,8 @@ module "safer_mysql" { user_labels = var.user_labels - backup_configuration = var.backup_configuration + backup_configuration = var.backup_configuration + retain_backups_on_delete = var.retain_backups_on_delete insights_config = var.insights_config diff --git a/modules/safer_mysql/variables.tf b/modules/safer_mysql/variables.tf index 33e37357..7b5ff289 100644 --- a/modules/safer_mysql/variables.tf +++ b/modules/safer_mysql/variables.tf @@ -237,6 +237,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 = true +} + variable "assign_public_ip" { description = "Set to true if the master instance should also have a public IP (less secure)." type = bool diff --git a/modules/safer_mysql/versions.tf b/modules/safer_mysql/versions.tf index d20bdb38..f6b4d204 100644 --- a/modules/safer_mysql/versions.tf +++ b/modules/safer_mysql/versions.tf @@ -20,7 +20,7 @@ terraform { google = { source = "hashicorp/google" - version = ">= 6.17, < 7" + version = ">= 6.31, < 7" } }