From b96cd3ab0d498658de27b393a598308c941c0cbb Mon Sep 17 00:00:00 2001 From: Zheng Qin Date: Fri, 13 Sep 2024 11:09:53 -0400 Subject: [PATCH 01/11] Update defaults for mysql module --- modules/mysql/variables.tf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/mysql/variables.tf b/modules/mysql/variables.tf index 7730f8ff..c787b290 100644 --- a/modules/mysql/variables.tf +++ b/modules/mysql/variables.tf @@ -73,7 +73,7 @@ variable "tier" { variable "edition" { description = "The edition of the instance, can be ENTERPRISE or ENTERPRISE_PLUS." type = string - default = null + default = "ENTERPRISE_PLUS" } variable "zone" { @@ -109,7 +109,7 @@ variable "availability_type" { variable "deletion_protection_enabled" { description = "Enables protection of an instance from accidental deletion across all surfaces (API, gcloud, Cloud Console and Terraform)." type = bool - default = false + default = true } variable "read_replica_deletion_protection_enabled" { @@ -185,7 +185,7 @@ variable "user_labels" { variable "data_cache_enabled" { description = "Whether data cache is enabled for the instance. Defaults to false. Feature is only available for ENTERPRISE_PLUS tier and supported database_versions" type = bool - default = false + default = true } variable "deny_maintenance_period" { @@ -202,10 +202,10 @@ variable "backup_configuration" { description = "The backup_configuration settings subblock for the database setings" type = object({ binary_log_enabled = optional(bool, false) - enabled = optional(bool, false) + enabled = optional(bool, true) start_time = optional(string) location = optional(string) - point_in_time_recovery_enabled = optional(bool, false) + point_in_time_recovery_enabled = optional(bool, true) transaction_log_retention_days = optional(string) retained_backups = optional(number) retention_unit = optional(string) From 91953f7eed5a8392d7df5d86d4c08437185eaa5a Mon Sep 17 00:00:00 2001 From: Zheng Qin Date: Fri, 13 Sep 2024 11:43:10 -0400 Subject: [PATCH 02/11] set default to database flags --- modules/mysql/variables.tf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/mysql/variables.tf b/modules/mysql/variables.tf index c787b290..f1753da3 100644 --- a/modules/mysql/variables.tf +++ b/modules/mysql/variables.tf @@ -172,7 +172,12 @@ variable "database_flags" { name = string value = string })) - default = [] + default = [ + { + name = "cloudsql_iam_authentication" + value = "true" + } + ] } From 9036b3339890caa07c071a49871254758f7c9f8c Mon Sep 17 00:00:00 2001 From: Zheng Qin Date: Wed, 18 Sep 2024 16:20:31 -0400 Subject: [PATCH 03/11] Update defaults for postgresql module --- modules/postgresql/variables.tf | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/postgresql/variables.tf b/modules/postgresql/variables.tf index f209440b..76339d8a 100644 --- a/modules/postgresql/variables.tf +++ b/modules/postgresql/variables.tf @@ -69,7 +69,7 @@ variable "tier" { variable "edition" { description = "The edition of the Cloud SQL instance, can be ENTERPRISE or ENTERPRISE_PLUS." type = string - default = null + default = "ENTERPRISE_PLUS" } variable "zone" { @@ -105,7 +105,7 @@ variable "availability_type" { variable "deletion_protection_enabled" { description = "Enables protection of an Cloud SQL instance from accidental deletion across all surfaces (API, gcloud, Cloud Console and Terraform)." type = bool - default = false + default = true } variable "read_replica_deletion_protection_enabled" { @@ -168,7 +168,12 @@ variable "database_flags" { name = string value = string })) - default = [] + default = [ + { + name = "cloudsql.iam_authentication", + value = "true" + } + ] } variable "user_labels" { @@ -190,10 +195,10 @@ variable "deny_maintenance_period" { variable "backup_configuration" { description = "The backup_configuration settings subblock for the database setings" type = object({ - enabled = optional(bool, false) + enabled = optional(bool, true) start_time = optional(string) location = optional(string) - point_in_time_recovery_enabled = optional(bool, false) + point_in_time_recovery_enabled = optional(bool, true) transaction_log_retention_days = optional(string) retained_backups = optional(number) retention_unit = optional(string) @@ -436,7 +441,7 @@ variable "root_password" { variable "data_cache_enabled" { description = "Whether data cache is enabled for the instance. Defaults to false. Feature is only available for ENTERPRISE_PLUS tier and supported database_versions" type = bool - default = false + default = true } variable "enable_google_ml_integration" { From 4d169b34394c08cddd3cbd51a9db2196138a3b8e Mon Sep 17 00:00:00 2001 From: Zheng Qin Date: Wed, 9 Oct 2024 17:33:44 -0400 Subject: [PATCH 04/11] Update alt_defaults for mysql dispaly yaml --- modules/mysql/metadata.display.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/mysql/metadata.display.yaml b/modules/mysql/metadata.display.yaml index cd896d5a..eaef4f1c 100644 --- a/modules/mysql/metadata.display.yaml +++ b/modules/mysql/metadata.display.yaml @@ -43,6 +43,9 @@ spec: backup_configuration: name: backup_configuration title: Backup Configuration + alt_defaults: + - type: ALTERNATE_TYPE_UNSPECIFIED + value: true connector_enforcement: name: connector_enforcement title: Connector Enforcement @@ -52,6 +55,9 @@ spec: data_cache_enabled: name: data_cache_enabled title: Data Cache Enabled + alt_defaults: + - type: ALTERNATE_TYPE_UNSPECIFIED + value: true database_flags: name: database_flags title: Database Flags @@ -79,12 +85,18 @@ spec: deletion_protection_enabled: name: deletion_protection_enabled title: Deletion Protection Enabled + alt_defaults: + - type: ALTERNATE_TYPE_UNSPECIFIED + value: true deny_maintenance_period: name: deny_maintenance_period title: Deny Maintenance Period disk_autoresize: name: disk_autoresize title: Disk Autoresize + alt_defaults: + - type: ALTERNATE_TYPE_UNSPECIFIED + value: true disk_autoresize_limit: name: disk_autoresize_limit title: Disk Autoresize Limit @@ -97,6 +109,9 @@ spec: edition: name: edition title: Edition + alt_defaults: + - type: ALTERNATE_TYPE_UNSPECIFIED + value: "ENTERPRISE_PLUS" enable_default_db: name: enable_default_db title: Enable Default Db From a7b2202fdc68f7e6e076dbf8bfccb7aadbdf8800 Mon Sep 17 00:00:00 2001 From: Zheng Qin Date: Wed, 9 Oct 2024 17:36:47 -0400 Subject: [PATCH 05/11] revert variables changes --- modules/mysql/variables.tf | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/modules/mysql/variables.tf b/modules/mysql/variables.tf index facc1ee8..9ea2a6d6 100644 --- a/modules/mysql/variables.tf +++ b/modules/mysql/variables.tf @@ -73,7 +73,7 @@ variable "tier" { variable "edition" { description = "The edition of the instance, can be ENTERPRISE or ENTERPRISE_PLUS." type = string - default = "ENTERPRISE_PLUS" + default = null } variable "zone" { @@ -109,7 +109,7 @@ variable "availability_type" { variable "deletion_protection_enabled" { description = "Enables protection of an instance from accidental deletion across all surfaces (API, gcloud, Cloud Console and Terraform)." type = bool - default = true + default = false } variable "read_replica_deletion_protection_enabled" { @@ -172,12 +172,7 @@ variable "database_flags" { name = string value = string })) - default = [ - { - name = "cloudsql_iam_authentication" - value = "true" - } - ] + default = [] } @@ -190,7 +185,7 @@ variable "user_labels" { variable "data_cache_enabled" { description = "Whether data cache is enabled for the instance. Defaults to false. Feature is only available for ENTERPRISE_PLUS tier and supported database_versions" type = bool - default = true + default = false } variable "deny_maintenance_period" { @@ -207,10 +202,10 @@ variable "backup_configuration" { description = "The backup_configuration settings subblock for the database setings" type = object({ binary_log_enabled = optional(bool, false) - enabled = optional(bool, true) + enabled = optional(bool, false) start_time = optional(string) location = optional(string) - point_in_time_recovery_enabled = optional(bool, true) + point_in_time_recovery_enabled = optional(bool, false) transaction_log_retention_days = optional(string) retained_backups = optional(number) retention_unit = optional(string) From c8903f840c326e53119cec36e892371866bd57f9 Mon Sep 17 00:00:00 2001 From: Zheng Qin Date: Wed, 9 Oct 2024 17:37:39 -0400 Subject: [PATCH 06/11] revert postgresql variables changes --- modules/postgresql/variables.tf | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/modules/postgresql/variables.tf b/modules/postgresql/variables.tf index 76339d8a..f209440b 100644 --- a/modules/postgresql/variables.tf +++ b/modules/postgresql/variables.tf @@ -69,7 +69,7 @@ variable "tier" { variable "edition" { description = "The edition of the Cloud SQL instance, can be ENTERPRISE or ENTERPRISE_PLUS." type = string - default = "ENTERPRISE_PLUS" + default = null } variable "zone" { @@ -105,7 +105,7 @@ variable "availability_type" { variable "deletion_protection_enabled" { description = "Enables protection of an Cloud SQL instance from accidental deletion across all surfaces (API, gcloud, Cloud Console and Terraform)." type = bool - default = true + default = false } variable "read_replica_deletion_protection_enabled" { @@ -168,12 +168,7 @@ variable "database_flags" { name = string value = string })) - default = [ - { - name = "cloudsql.iam_authentication", - value = "true" - } - ] + default = [] } variable "user_labels" { @@ -195,10 +190,10 @@ variable "deny_maintenance_period" { variable "backup_configuration" { description = "The backup_configuration settings subblock for the database setings" type = object({ - enabled = optional(bool, true) + enabled = optional(bool, false) start_time = optional(string) location = optional(string) - point_in_time_recovery_enabled = optional(bool, true) + point_in_time_recovery_enabled = optional(bool, false) transaction_log_retention_days = optional(string) retained_backups = optional(number) retention_unit = optional(string) @@ -441,7 +436,7 @@ variable "root_password" { variable "data_cache_enabled" { description = "Whether data cache is enabled for the instance. Defaults to false. Feature is only available for ENTERPRISE_PLUS tier and supported database_versions" type = bool - default = true + default = false } variable "enable_google_ml_integration" { From acca7507803d4782f93227ad2405c7114749a786 Mon Sep 17 00:00:00 2001 From: Zheng Qin Date: Tue, 15 Oct 2024 13:30:42 -0400 Subject: [PATCH 07/11] Update the alt default type, add more new defaults for mysql module --- modules/mysql/metadata.display.yaml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/mysql/metadata.display.yaml b/modules/mysql/metadata.display.yaml index eaef4f1c..5172c1b2 100644 --- a/modules/mysql/metadata.display.yaml +++ b/modules/mysql/metadata.display.yaml @@ -40,11 +40,14 @@ spec: availability_type: name: availability_type title: Availability Type + alt_defaults: + - type: ALTERNATE_TYPE_DC + value: REGIONAL backup_configuration: name: backup_configuration title: Backup Configuration alt_defaults: - - type: ALTERNATE_TYPE_UNSPECIFIED + - type: ALTERNATE_TYPE_DC value: true connector_enforcement: name: connector_enforcement @@ -56,11 +59,16 @@ spec: name: data_cache_enabled title: Data Cache Enabled alt_defaults: - - type: ALTERNATE_TYPE_UNSPECIFIED + - type: ALTERNATE_TYPE_DC value: true database_flags: name: database_flags title: Database Flags + alt_defaults: + - type: ALTERNATE_TYPE_DC + value: + - name: "cloudsql_iam_authentication", + value: "on" database_integration_roles: name: database_integration_roles title: Database Integration Roles @@ -86,7 +94,7 @@ spec: name: deletion_protection_enabled title: Deletion Protection Enabled alt_defaults: - - type: ALTERNATE_TYPE_UNSPECIFIED + - type: ALTERNATE_TYPE_DC value: true deny_maintenance_period: name: deny_maintenance_period @@ -95,7 +103,7 @@ spec: name: disk_autoresize title: Disk Autoresize alt_defaults: - - type: ALTERNATE_TYPE_UNSPECIFIED + - type: ALTERNATE_TYPE_DC value: true disk_autoresize_limit: name: disk_autoresize_limit @@ -110,7 +118,7 @@ spec: name: edition title: Edition alt_defaults: - - type: ALTERNATE_TYPE_UNSPECIFIED + - type: ALTERNATE_TYPE_DC value: "ENTERPRISE_PLUS" enable_default_db: name: enable_default_db From cd5fd7185f38073b00d948268fe7462c1d6373c9 Mon Sep 17 00:00:00 2001 From: Zheng Qin Date: Tue, 15 Oct 2024 13:45:17 -0400 Subject: [PATCH 08/11] Add new defaults for postgres --- modules/mysql/metadata.display.yaml | 2 +- modules/postgresql/metadata.display.yaml | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/modules/mysql/metadata.display.yaml b/modules/mysql/metadata.display.yaml index 5172c1b2..0027ab08 100644 --- a/modules/mysql/metadata.display.yaml +++ b/modules/mysql/metadata.display.yaml @@ -119,7 +119,7 @@ spec: title: Edition alt_defaults: - type: ALTERNATE_TYPE_DC - value: "ENTERPRISE_PLUS" + value: ENTERPRISE_PLUS enable_default_db: name: enable_default_db title: Enable Default Db diff --git a/modules/postgresql/metadata.display.yaml b/modules/postgresql/metadata.display.yaml index 4317b75e..c84a186b 100644 --- a/modules/postgresql/metadata.display.yaml +++ b/modules/postgresql/metadata.display.yaml @@ -40,9 +40,15 @@ spec: availability_type: name: availability_type title: Availability Type + alt_defaults: + - type: ALTERNATE_TYPE_DC + value: REGIONAL backup_configuration: name: backup_configuration title: Backup Configuration + alt_defaults: + - type: ALTERNATE_TYPE_DC + value: true connector_enforcement: name: connector_enforcement title: Connector Enforcement @@ -58,6 +64,11 @@ spec: database_flags: name: database_flags title: Database Flags + alt_defaults: + - type: ALTERNATE_TYPE_DC + value: + - name: "cloudsql.iam_authentication", + value: "on" database_integration_roles: name: database_integration_roles title: Database Integration Roles @@ -82,12 +93,18 @@ spec: deletion_protection_enabled: name: deletion_protection_enabled title: Deletion Protection Enabled + alt_defaults: + - type: ALTERNATE_TYPE_DC + value: true deny_maintenance_period: name: deny_maintenance_period title: Deny Maintenance Period disk_autoresize: name: disk_autoresize title: Disk Autoresize + alt_defaults: + - type: ALTERNATE_TYPE_DC + value: true disk_autoresize_limit: name: disk_autoresize_limit title: Disk Autoresize Limit @@ -100,6 +117,9 @@ spec: edition: name: edition title: Edition + alt_defaults: + - type: ALTERNATE_TYPE_DC + value: ENTERPRISE_PLUS enable_default_db: name: enable_default_db title: Enable Default Db From dba5ec152cf7f3c051eac7b29dce889257d8102b Mon Sep 17 00:00:00 2001 From: Zheng Qin Date: Tue, 15 Oct 2024 15:21:22 -0400 Subject: [PATCH 09/11] Update backup_configuration defaults in both mysql and postgres --- modules/mysql/metadata.display.yaml | 6 +++++- modules/postgresql/metadata.display.yaml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/mysql/metadata.display.yaml b/modules/mysql/metadata.display.yaml index 0027ab08..8c69c0f4 100644 --- a/modules/mysql/metadata.display.yaml +++ b/modules/mysql/metadata.display.yaml @@ -48,7 +48,11 @@ spec: title: Backup Configuration alt_defaults: - type: ALTERNATE_TYPE_DC - value: true + value: + - name: enabled + value: true + - name: point_in_time_recovery_enabled + value: true connector_enforcement: name: connector_enforcement title: Connector Enforcement diff --git a/modules/postgresql/metadata.display.yaml b/modules/postgresql/metadata.display.yaml index c84a186b..1305c111 100644 --- a/modules/postgresql/metadata.display.yaml +++ b/modules/postgresql/metadata.display.yaml @@ -48,7 +48,11 @@ spec: title: Backup Configuration alt_defaults: - type: ALTERNATE_TYPE_DC - value: true + value: + - name: enabled + value: true + - name: point_in_time_recovery_enabled + value: true connector_enforcement: name: connector_enforcement title: Connector Enforcement From cb33e164993eff278f8e16f63cc48280d5678d9d Mon Sep 17 00:00:00 2001 From: Zheng Qin Date: Wed, 16 Oct 2024 12:00:29 -0400 Subject: [PATCH 10/11] backup config should be an object --- modules/mysql/metadata.display.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/mysql/metadata.display.yaml b/modules/mysql/metadata.display.yaml index 8c69c0f4..d748c89e 100644 --- a/modules/mysql/metadata.display.yaml +++ b/modules/mysql/metadata.display.yaml @@ -49,10 +49,8 @@ spec: alt_defaults: - type: ALTERNATE_TYPE_DC value: - - name: enabled - value: true - - name: point_in_time_recovery_enabled - value: true + enabled: true + point_in_time_recovery_enabled: true connector_enforcement: name: connector_enforcement title: Connector Enforcement From 592a1cb404361f8c3c9215ef8f89f47f9b3a6f24 Mon Sep 17 00:00:00 2001 From: Zheng Qin Date: Thu, 17 Oct 2024 10:45:37 -0400 Subject: [PATCH 11/11] address review comments --- modules/mysql/metadata.display.yaml | 2 +- modules/postgresql/metadata.display.yaml | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/mysql/metadata.display.yaml b/modules/mysql/metadata.display.yaml index d748c89e..69ef8c80 100644 --- a/modules/mysql/metadata.display.yaml +++ b/modules/mysql/metadata.display.yaml @@ -69,7 +69,7 @@ spec: alt_defaults: - type: ALTERNATE_TYPE_DC value: - - name: "cloudsql_iam_authentication", + - name: "cloudsql_iam_authentication" value: "on" database_integration_roles: name: database_integration_roles diff --git a/modules/postgresql/metadata.display.yaml b/modules/postgresql/metadata.display.yaml index 1305c111..479122c4 100644 --- a/modules/postgresql/metadata.display.yaml +++ b/modules/postgresql/metadata.display.yaml @@ -49,10 +49,8 @@ spec: alt_defaults: - type: ALTERNATE_TYPE_DC value: - - name: enabled - value: true - - name: point_in_time_recovery_enabled - value: true + enabled: true + point_in_time_recovery_enabled: true connector_enforcement: name: connector_enforcement title: Connector Enforcement @@ -62,6 +60,9 @@ spec: data_cache_enabled: name: data_cache_enabled title: Data Cache Enabled + alt_defaults: + - type: ALTERNATE_TYPE_DC + value: true database_deletion_policy: name: database_deletion_policy title: Database Deletion Policy @@ -71,7 +72,7 @@ spec: alt_defaults: - type: ALTERNATE_TYPE_DC value: - - name: "cloudsql.iam_authentication", + - name: "cloudsql.iam_authentication" value: "on" database_integration_roles: name: database_integration_roles