From e734ea2b24fa944ed6f0f7b5e26d861c4f05bc8f Mon Sep 17 00:00:00 2001 From: Nitya Navali Date: Mon, 23 Oct 2023 16:15:59 +0000 Subject: [PATCH] adding data_cache to postgresql --- modules/postgresql/README.md | 1 + modules/postgresql/main.tf | 6 ++++++ modules/postgresql/variables.tf | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/modules/postgresql/README.md b/modules/postgresql/README.md index 7b74bfbd..bd3cc467 100644 --- a/modules/postgresql/README.md +++ b/modules/postgresql/README.md @@ -14,6 +14,7 @@ Note: CloudSQL provides [disk autoresize](https://cloud.google.com/sql/docs/mysq | backup\_configuration | The backup\_configuration settings subblock for the database setings |
object({
enabled = optional(bool, false)
start_time = optional(string)
location = optional(string)
point_in_time_recovery_enabled = optional(bool, false)
transaction_log_retention_days = optional(string)
retained_backups = optional(number)
retention_unit = optional(string)
})
| `{}` | no | | connector\_enforcement | Enforce that clients use the connector library | `bool` | `false` | no | | create\_timeout | The optional timout that is applied to limit long database creates. | `string` | `"30m"` | no | +| 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 | | database\_deletion\_policy | The deletion policy for the database. Setting ABANDON allows the resource to be abandoned rather than deleted. This is useful for Postgres, where databases cannot be deleted from the API if there are users other than cloudsqlsuperuser with access. Possible values are: "ABANDON". | `string` | `null` | no | | database\_flags | The database flags for the master instance. See [more details](https://cloud.google.com/sql/docs/postgres/flags) |
list(object({
name = string
value = string
}))
| `[]` | no | | database\_version | The database version to use | `string` | n/a | yes | diff --git a/modules/postgresql/main.tf b/modules/postgresql/main.tf index 12737b92..e7d49705 100644 --- a/modules/postgresql/main.tf +++ b/modules/postgresql/main.tf @@ -85,6 +85,12 @@ resource "google_sql_database_instance" "default" { } } } + dynamic "data_cache_config" { + for_each = var.edition == "ENTERPRISE_PLUS" && var.data_cache_enabled ? ["cache_enabled"] : [] + content { + data_cache_enabled = var.data_cache_enabled + } + } dynamic "deny_maintenance_period" { for_each = var.deny_maintenance_period content { diff --git a/modules/postgresql/variables.tf b/modules/postgresql/variables.tf index 5adc094f..acf463f5 100644 --- a/modules/postgresql/variables.tf +++ b/modules/postgresql/variables.tf @@ -413,3 +413,9 @@ variable "connector_enforcement" { type = bool default = false } + +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 +}