Skip to content

Commit e67e0e0

Browse files
jmymyimrannayer
andauthored
feat(TPG>7.2)!: add final backup config (#786)
Co-authored-by: Imran Nayer <imrannayer@google.com>
1 parent db2e85f commit e67e0e0

File tree

19 files changed

+106
-9
lines changed

19 files changed

+106
-9
lines changed

docs/upgrading_to_sql_db_27.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Upgrading to v27.0
2+
3+
The v27.0 release contains backwards-incompatible changes.
4+
5+
This update requires upgrading the minimum provider version from `6.31` to `7.2`

modules/mssql/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ module "mssql" {
5959
| enable\_default\_db | Enable or disable the creation of the default database | `bool` | `true` | no |
6060
| enable\_default\_user | Enable or disable the creation of the default user | `bool` | `true` | no |
6161
| encryption\_key\_name | The full path to the encryption key used for the CMEK disk encryption | `string` | `null` | no |
62+
| final\_backup\_config | The final\_backup\_config settings for the database. | <pre>object({<br> enabled = optional(bool, false)<br> retention_days = optional(number, 0)<br> })</pre> | `null` | no |
6263
| follow\_gae\_application | A Google App Engine application whose zone to remain in. Must be in the same region as this instance. | `string` | `null` | no |
6364
| insights\_config | The insights\_config settings for the database. | <pre>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> })</pre> | `null` | no |
6465
| instance\_type | The type of the instance. The supported values are SQL\_INSTANCE\_TYPE\_UNSPECIFIED, CLOUD\_SQL\_INSTANCE, ON\_PREMISES\_INSTANCE and READ\_REPLICA\_INSTANCE. Set to READ\_REPLICA\_INSTANCE when primary\_instance\_name is provided | `string` | `"CLOUD_SQL_INSTANCE"` | no |

modules/mssql/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ resource "google_sql_database_instance" "default" {
128128
record_client_address = lookup(insights_config.value, "record_client_address", false)
129129
}
130130
}
131+
dynamic "final_backup_config" {
132+
for_each = var.final_backup_config != null ? [var.final_backup_config] : []
133+
134+
content {
135+
enabled = lookup(final_backup_config.value, "enabled", false)
136+
retention_days = lookup(final_backup_config.value, "retention_days", 0)
137+
}
138+
}
131139

132140
disk_autoresize = var.disk_autoresize
133141
disk_autoresize_limit = var.disk_autoresize_limit

modules/mssql/variables.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,12 @@ variable "insights_config" {
385385
})
386386
default = null
387387
}
388+
389+
variable "final_backup_config" {
390+
description = "The final_backup_config settings for the database."
391+
type = object({
392+
enabled = optional(bool, false)
393+
retention_days = optional(number, 0)
394+
})
395+
default = null
396+
}

modules/mssql/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ terraform {
1919
required_providers {
2020
google = {
2121
source = "hashicorp/google"
22-
version = ">= 5.12, < 8"
22+
version = ">= 7.2, < 8"
2323
}
2424
google-beta = {
2525
source = "hashicorp/google-beta"
26-
version = ">= 5.12, < 8"
26+
version = ">= 7.2, < 8"
2727
}
2828
random = {
2929
source = "hashicorp/random"

modules/mysql/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ module "mysql-db" {
7575
| enable\_random\_password\_special | Enable special characters in generated random passwords. | `bool` | `false` | no |
7676
| encryption\_key\_name | The full path to the encryption key used for the CMEK disk encryption | `string` | `null` | no |
7777
| failover\_dr\_replica\_name | If the instance is a primary instance, then this field identifies the disaster recovery (DR) replica. The standard format of this field is "your-project:your-instance". You can also set this field to "your-instance", but cloud SQL backend will convert it to the aforementioned standard format. | `string` | `null` | no |
78+
| final\_backup\_config | The final\_backup\_config settings for the database. | <pre>object({<br> enabled = optional(bool, false)<br> retention_days = optional(number, 0)<br> })</pre> | `null` | no |
7879
| follow\_gae\_application | A Google App Engine application whose zone to remain in. Must be in the same region as this instance. | `string` | `null` | no |
7980
| iam\_users | A list of IAM users to be created in your CloudSQL instance. iam.users.type can be CLOUD\_IAM\_USER, CLOUD\_IAM\_SERVICE\_ACCOUNT, CLOUD\_IAM\_GROUP and is required for type CLOUD\_IAM\_GROUP (IAM groups) | <pre>list(object({<br> id = string,<br> email = string,<br> type = optional(string)<br> }))</pre> | `[]` | no |
8081
| insights\_config | The insights\_config settings for the database. | <pre>object({<br> query_plans_per_minute = number<br> query_string_length = number<br> record_application_tags = bool<br> record_client_address = bool<br> })</pre> | `null` | no |
@@ -94,7 +95,7 @@ module "mysql-db" {
9495
| read\_replica\_deletion\_protection | Used to block Terraform from deleting replica SQL Instances. | `bool` | `false` | no |
9596
| read\_replica\_deletion\_protection\_enabled | Enables protection of a read replica from accidental deletion across all surfaces (API, gcloud, Cloud Console and Terraform). | `bool` | `false` | no |
9697
| read\_replica\_name\_suffix | The optional suffix to add to the read instance name | `string` | `""` | no |
97-
| 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 |
98+
| 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> final_backup_config = optional(object({<br> enabled = optional(bool, false)<br> retention_days = optional(number, 1)<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 |
9899
| region | The region of the Cloud SQL resources | `string` | `"us-central1"` | no |
99100
| 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 |
100101
| 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 |

modules/mysql/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ resource "google_sql_database_instance" "default" {
112112
record_client_address = lookup(insights_config.value, "record_client_address", false)
113113
}
114114
}
115+
dynamic "final_backup_config" {
116+
for_each = var.final_backup_config != null ? [var.final_backup_config] : []
117+
118+
content {
119+
enabled = lookup(final_backup_config.value, "enabled", false)
120+
retention_days = lookup(final_backup_config.value, "retention_days", 0)
121+
}
122+
}
115123
dynamic "data_cache_config" {
116124
for_each = var.edition == "ENTERPRISE_PLUS" ? ["cache_enabled"] : []
117125
content {

modules/mysql/read_replica.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ resource "google_sql_database_instance" "replicas" {
7070
}
7171
}
7272

73+
dynamic "final_backup_config" {
74+
for_each = var.final_backup_config != null ? [var.final_backup_config] : []
75+
76+
content {
77+
enabled = lookup(final_backup_config.value, "enabled", false)
78+
retention_days = lookup(final_backup_config.value, "retention_days", 0)
79+
}
80+
}
81+
7382
dynamic "ip_configuration" {
7483
for_each = [lookup(each.value, "ip_configuration", {})]
7584
content {

modules/mysql/variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,15 @@ variable "insights_config" {
331331
default = null
332332
}
333333

334+
variable "final_backup_config" {
335+
description = "The final_backup_config settings for the database."
336+
type = object({
337+
enabled = optional(bool, false)
338+
retention_days = optional(number, 0)
339+
})
340+
default = null
341+
}
342+
334343
variable "ip_configuration" {
335344
description = "The ip_configuration settings subblock"
336345
type = object({
@@ -387,6 +396,10 @@ variable "read_replicas" {
387396
record_application_tags = bool
388397
record_client_address = bool
389398
}))
399+
final_backup_config = optional(object({
400+
enabled = optional(bool, false)
401+
retention_days = optional(number, 1)
402+
}), null)
390403
ip_configuration = object({
391404
authorized_networks = optional(list(map(string)), [])
392405
ipv4_enabled = optional(bool)

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.31, < 8"
30+
version = ">= 7.2, < 8"
3131
}
3232
google-beta = {
3333
source = "hashicorp/google-beta"
34-
version = ">= 6.31, < 8"
34+
version = ">= 7.2, < 8"
3535
}
3636
}
3737

0 commit comments

Comments
 (0)