From ccd8e9c8018878ff28ea4071a87adb7af986c692 Mon Sep 17 00:00:00 2001 From: Sven Schliesing Date: Thu, 23 Jan 2025 15:06:57 +0100 Subject: [PATCH 1/2] feat: Add variables "enable_default_db", "enable_default_user" to module "safer_mysql" --- modules/safer_mysql/main.tf | 8 +++++--- modules/safer_mysql/variables.tf | 12 ++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/safer_mysql/main.tf b/modules/safer_mysql/main.tf index 2aaada4a..2f9b7a5e 100644 --- a/modules/safer_mysql/main.tf +++ b/modules/safer_mysql/main.tf @@ -60,11 +60,13 @@ module "safer_mysql" { allocated_ip_range = var.allocated_ip_range } - db_name = var.db_name - db_charset = var.db_charset - db_collation = var.db_collation + enable_default_db = var.enable_default_db + db_name = var.db_name + db_charset = var.db_charset + db_collation = var.db_collation additional_databases = var.additional_databases + enable_default_user = var.enable_default_user user_name = var.user_name // All MySQL users can connect only via the Cloud SQL Proxy. diff --git a/modules/safer_mysql/variables.tf b/modules/safer_mysql/variables.tf index 1d3afc6b..9df45272 100644 --- a/modules/safer_mysql/variables.tf +++ b/modules/safer_mysql/variables.tf @@ -258,6 +258,12 @@ variable "read_replicas" { default = [] } +variable "enable_default_db" { + description = "Enable or disable the creation of the default database" + type = bool + default = true +} + variable "db_name" { description = "The name of the default database to create" type = string @@ -286,6 +292,12 @@ variable "additional_databases" { default = [] } +variable "enable_default_user" { + description = "Enable or disable the creation of the default user" + type = bool + default = true +} + variable "user_name" { description = "The name of the default user" type = string From 4fd237070197e1620442c1442764159c2b9accfc Mon Sep 17 00:00:00 2001 From: Sven Schliesing Date: Thu, 23 Jan 2025 16:07:55 +0100 Subject: [PATCH 2/2] fix documentation --- modules/safer_mysql/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/safer_mysql/README.md b/modules/safer_mysql/README.md index ae4bb296..bcd44e2b 100644 --- a/modules/safer_mysql/README.md +++ b/modules/safer_mysql/README.md @@ -261,6 +261,8 @@ module "safer-mysql-db" { | disk\_size | The disk size for the master instance | `number` | `10` | no | | disk\_type | The disk type for the master instance. | `string` | `"PD_SSD"` | no | | edition | The edition of the instance, can be ENTERPRISE or ENTERPRISE\_PLUS. | `string` | `null` | no | +| enable\_default\_db | Enable or disable the creation of the default database | `bool` | `true` | no | +| enable\_default\_user | Enable or disable the creation of the default user | `bool` | `true` | no | | encryption\_key\_name | The full path to the encryption key used for the CMEK disk encryption | `string` | `null` | no | | 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 | | 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) |
list(object({
id = string,
email = string,
type = optional(string)
}))
| `[]` | no |