Skip to content

Commit 0024b24

Browse files
ibhaskar2g-awmalik
andauthored
feat!: added edition in mssql, mysql, postgresql, safer_sql and data_cache_config to mysql and safer_sql modules (#491)
Co-authored-by: Awais Malik <[email protected]>
1 parent ae083ea commit 0024b24

File tree

18 files changed

+66
-9
lines changed

18 files changed

+66
-9
lines changed

modules/mssql/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ The following dependency must be available for SQL Server module:
2929
| disk\_autoresize\_limit | The maximum size to which storage can be auto increased. | `number` | `0` | no |
3030
| disk\_size | The disk size for the master instance. | `number` | `10` | no |
3131
| disk\_type | The disk type for the master instance. | `string` | `"PD_SSD"` | no |
32+
| edition | The edition of the instance, can be ENTERPRISE or ENTERPRISE\_PLUS. | `string` | `null` | no |
3233
| encryption\_key\_name | The full path to the encryption key used for the CMEK disk encryption | `string` | `null` | no |
3334
| 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 |
3435
| ip\_configuration | The ip configuration for the master instances. | <pre>object({<br> authorized_networks = list(map(string))<br> ipv4_enabled = bool<br> private_network = string<br> require_ssl = bool<br> allocated_ip_range = string<br> })</pre> | <pre>{<br> "allocated_ip_range": null,<br> "authorized_networks": [],<br> "ipv4_enabled": true,<br> "private_network": null,<br> "require_ssl": null<br>}</pre> | no |

modules/mssql/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ resource "google_sql_database_instance" "default" {
5252

5353
settings {
5454
tier = var.tier
55+
edition = var.edition
5556
activation_policy = var.activation_policy
5657
availability_type = var.availability_type
5758
deletion_protection_enabled = var.deletion_protection_enabled

modules/mssql/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ variable "tier" {
5050
default = "db-custom-2-3840"
5151
}
5252

53+
variable "edition" {
54+
description = "The edition of the instance, can be ENTERPRISE or ENTERPRISE_PLUS."
55+
type = string
56+
default = null
57+
}
58+
5359
variable "zone" {
5460
type = string
5561
description = "The zone for the master instance."

modules/mssql/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ terraform {
2020

2121
google = {
2222
source = "hashicorp/google"
23-
version = ">= 4.48.0, < 5.0"
23+
version = ">= 4.74.0, < 5.0"
2424
}
2525
google-beta = {
2626
source = "hashicorp/google-beta"
27-
version = ">= 4.48.0, < 5.0"
27+
version = ">= 4.74.0, < 5.0"
2828
}
2929
random = {
3030
source = "hashicorp/random"

modules/mysql/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
1414
| backup\_configuration | The backup\_configuration settings subblock for the database setings | <pre>object({<br> binary_log_enabled = bool<br> enabled = bool<br> start_time = string<br> location = string<br> transaction_log_retention_days = string<br> retained_backups = number<br> retention_unit = string<br> })</pre> | <pre>{<br> "binary_log_enabled": false,<br> "enabled": false,<br> "location": null,<br> "retained_backups": null,<br> "retention_unit": null,<br> "start_time": null,<br> "transaction_log_retention_days": null<br>}</pre> | no |
1515
| connector\_enforcement | Enforce that clients use the connector library | `bool` | `false` | no |
1616
| create\_timeout | The optional timout that is applied to limit long database creates. | `string` | `"30m"` | no |
17+
| data\_cache\_enabled | Whether data cache is enabled for the instance. Defaults to false. Feature is only available for ENTERPRISE\_PLUS tier and supported database\_versions | `bool` | `false` | no |
1718
| database\_flags | List of Cloud SQL flags that are applied to the database server. See [more details](https://cloud.google.com/sql/docs/mysql/flags) | <pre>list(object({<br> name = string<br> value = string<br> }))</pre> | `[]` | no |
1819
| database\_version | The database version to use | `string` | n/a | yes |
1920
| db\_charset | The charset for the default database | `string` | `""` | no |
@@ -27,6 +28,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
2728
| disk\_autoresize\_limit | The maximum size to which storage can be auto increased. | `number` | `0` | no |
2829
| disk\_size | The disk size for the master instance | `number` | `10` | no |
2930
| disk\_type | The disk type for the master instance. | `string` | `"PD_SSD"` | no |
31+
| edition | The edition of the instance, can be ENTERPRISE or ENTERPRISE\_PLUS. | `string` | `null` | no |
3032
| enable\_default\_db | Enable or disable the creation of the default database | `bool` | `true` | no |
3133
| enable\_default\_user | Enable or disable the creation of the default user | `bool` | `true` | no |
3234
| enable\_random\_password\_special | Enable special characters in generated random passwords. | `bool` | `false` | no |
@@ -47,7 +49,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
4749
| read\_replica\_deletion\_protection | Used to block Terraform from deleting replica SQL Instances. | `bool` | `false` | no |
4850
| 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 |
4951
| read\_replica\_name\_suffix | The optional suffix to add to the read instance name | `string` | `""` | no |
50-
| 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> zone = string<br> availability_type = 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_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> require_ssl = bool<br> allocated_ip_range = string<br> enable_private_path_for_google_cloud_services = optional(bool)<br> })<br> encryption_key_name = string<br> }))</pre> | `[]` | no |
52+
| 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 = optional(string)<br> zone = string<br> availability_type = 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_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> require_ssl = bool<br> allocated_ip_range = string<br> enable_private_path_for_google_cloud_services = optional(bool)<br> })<br> encryption_key_name = string<br> }))</pre> | `[]` | no |
5153
| region | The region of the Cloud SQL resources | `string` | `"us-central1"` | no |
5254
| 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 |
5355
| root\_password | Mysql password for the root user. If not set, a random one will be generated and available in the root\_password output variable. | `string` | `""` | no |

modules/mysql/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ resource "google_sql_database_instance" "default" {
6161

6262
settings {
6363
tier = var.tier
64+
edition = var.edition
6465
activation_policy = var.activation_policy
6566
availability_type = var.availability_type
6667
deletion_protection_enabled = var.deletion_protection_enabled
@@ -94,6 +95,12 @@ resource "google_sql_database_instance" "default" {
9495
record_client_address = lookup(insights_config.value, "record_client_address", false)
9596
}
9697
}
98+
dynamic "data_cache_config" {
99+
for_each = var.edition == "ENTERPRISE_PLUS" && var.data_cache_enabled ? ["cache_enabled"] : []
100+
content {
101+
data_cache_enabled = var.data_cache_enabled
102+
}
103+
}
97104
dynamic "deny_maintenance_period" {
98105
for_each = var.deny_maintenance_period
99106
content {

modules/mysql/read_replica.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ resource "google_sql_database_instance" "replicas" {
3737

3838
settings {
3939
tier = lookup(each.value, "tier", var.tier)
40+
edition = lookup(each.value, "edition", var.edition)
4041
activation_policy = "ALWAYS"
4142
availability_type = lookup(each.value, "availability_type", var.availability_type)
4243
deletion_protection_enabled = var.read_replica_deletion_protection_enabled

modules/mysql/variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ variable "tier" {
5656
default = "db-n1-standard-1"
5757
}
5858

59+
variable "edition" {
60+
description = "The edition of the instance, can be ENTERPRISE or ENTERPRISE_PLUS."
61+
type = string
62+
default = null
63+
}
64+
5965
variable "zone" {
6066
description = "The zone for the master instance, it should be something like: `us-central1-a`, `us-east1-c`."
6167
type = string
@@ -161,6 +167,12 @@ variable "user_labels" {
161167
description = "The key/value labels for the master instances."
162168
}
163169

170+
variable "data_cache_enabled" {
171+
description = "Whether data cache is enabled for the instance. Defaults to false. Feature is only available for ENTERPRISE_PLUS tier and supported database_versions"
172+
type = bool
173+
default = false
174+
}
175+
164176
variable "deny_maintenance_period" {
165177
description = "The Deny Maintenance Period fields to prevent automatic maintenance from occurring during a 90-day time period. See [more details](https://cloud.google.com/sql/docs/mysql/maintenance)"
166178
type = list(object({
@@ -241,6 +253,7 @@ variable "read_replicas" {
241253
name = string
242254
name_override = optional(string)
243255
tier = string
256+
edition = optional(string)
244257
zone = string
245258
availability_type = string
246259
disk_type = string

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 = ">= 4.48.0, < 5.0"
30+
version = ">= 4.74.0, < 5.0"
3131
}
3232
google-beta = {
3333
source = "hashicorp/google-beta"
34-
version = ">= 4.48.0, < 5.0"
34+
version = ">= 4.47.0, < 5.0"
3535
}
3636
}
3737

modules/postgresql/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq
2727
| disk\_autoresize\_limit | The maximum size to which storage can be auto increased. | `number` | `0` | no |
2828
| disk\_size | The disk size for the master instance. | `number` | `10` | no |
2929
| disk\_type | The disk type for the master instance. | `string` | `"PD_SSD"` | no |
30+
| edition | The edition of the instance, can be ENTERPRISE or ENTERPRISE\_PLUS. | `string` | `null` | no |
3031
| enable\_default\_db | Enable or disable the creation of the default database | `bool` | `true` | no |
3132
| enable\_default\_user | Enable or disable the creation of the default user | `bool` | `true` | no |
3233
| enable\_random\_password\_special | Enable special characters in generated random passwords. | `bool` | `false` | no |

0 commit comments

Comments
 (0)