diff --git a/docs/upgrading_to_v9.0.md b/docs/upgrading_to_v9.0.md index ce85453..5636f49 100644 --- a/docs/upgrading_to_v9.0.md +++ b/docs/upgrading_to_v9.0.md @@ -1,5 +1,6 @@ -# Upgrading to v9.0.0 +# Upgrading to v9.0 The v9.0 release contains backwards-incompatible changes. -This update requires upgrading the minimum provider version to `5.24`. +# Min Provider Version +This update requires upgrading the minimum provider version to `5.28.` to support `node_type` and `redis_configs` parameters. diff --git a/examples/redis-cluster/main.tf b/examples/redis-cluster/main.tf index 03c93a3..5a94ad6 100644 --- a/examples/redis-cluster/main.tf +++ b/examples/redis-cluster/main.tf @@ -16,12 +16,13 @@ module "redis_cluster" { source = "terraform-google-modules/memorystore/google//modules/redis-cluster" - version = "~> 8.0" - - name = "test-redis-cluster" - project = var.project_id - region = "us-central1" - network = ["projects/${var.project_id}/global/networks/${local.network_name}"] + version = "~> 9.0" + + name = "test-redis-cluster" + project = var.project_id + region = "us-central1" + network = ["projects/${var.project_id}/global/networks/${local.network_name}"] + node_type = "REDIS_STANDARD_SMALL" service_connection_policies = { test-net-redis-cluster-scp = { @@ -33,5 +34,10 @@ module "redis_cluster" { ] } } + + redis_configs = { + maxmemory-policy = "volatile-ttl" + } + depends_on = [module.test_vpc] } diff --git a/modules/redis-cluster/README.md b/modules/redis-cluster/README.md index ba9cb89..387e76e 100644 --- a/modules/redis-cluster/README.md +++ b/modules/redis-cluster/README.md @@ -10,23 +10,18 @@ This module is meant for use with Terraform 1.3+ and tested using Terraform 1.3+ ``` module "redis_cluster" { source = "terraform-google-modules/memorystore/google//modules/redis-cluster" - version = "~> 8.0" + version = "~> 9.0" name = "test-redis-cluster" project = var.project_id region = "us-central1" - network = ["projects/${var.project_id}/global/networks/${local.network_name}"] - - service_connection_policies = { - test-net-redis-cluster-scp = { - network_name = local.network_name - network_project = var.project_id - subnet_names = [ - "subnet-100", - "subnet-101", - ] - } + network = ["projects/${var.project_id}/global/networks/${var.network_name}"] + node_type = "REDIS_STANDARD_SMALL" + + redis_configs = { + maxmemory-policy = "volatile-ttl" } + } ``` @@ -41,6 +36,7 @@ module "redis_cluster" { | network | List of consumer network where the network address of the discovery endpoint will be reserved, in the form of projects/{network\_project\_id\_or\_number}/global/networks/{network\_id}. Currently, only one item is supported | `list(string)` | n/a | yes | | node\_type | The nodeType for the Redis cluster. If not provided, REDIS\_HIGHMEM\_MEDIUM will be used as default Possible values are: REDIS\_SHARED\_CORE\_NANO, REDIS\_HIGHMEM\_MEDIUM, REDIS\_HIGHMEM\_XLARGE, REDIS\_STANDARD\_SMALL. | `string` | `null` | no | | project | The ID of the project in which the resource belongs to. | `string` | n/a | yes | +| redis\_configs | Configure Redis Cluster behavior using a subset of native Redis configuration parameters |
object({
maxmemory-clients = optional(string)
maxmemory = optional(string)
maxmemory-policy = optional(string)
notify-keyspace-events = optional(string)
slowlog-log-slower-than = optional(number)
maxclients = optional(number)
})
| `null` | no | | region | The name of the region of the Redis cluster | `string` | n/a | yes | | replica\_count | The number of replica nodes per shard. Each shard can have 0, 1, or 2 replica nodes. Replicas provide high availability and additional read throughput, and are evenly distributed across zones | `number` | `0` | no | | service\_connection\_policies | The Service Connection Policies to create |
map(object({
description = optional(string)
network_name = string
network_project = string
subnet_names = list(string)
limit = optional(number)
labels = optional(map(string), {})
}))
| `{}` | no | @@ -67,7 +63,7 @@ These sections describe requirements for using this module. The following dependencies must be available: - [Terraform][terraform] v1.3+ -- [Terraform Provider for GCP][terraform-provider-gcp] plugin v4.74+ +- [Terraform Provider for GCP][terraform-provider-gcp] plugin v5.28+ ### Service Account diff --git a/modules/redis-cluster/main.tf b/modules/redis-cluster/main.tf index 3520581..5dfd39e 100644 --- a/modules/redis-cluster/main.tf +++ b/modules/redis-cluster/main.tf @@ -23,6 +23,7 @@ resource "google_redis_cluster" "redis_cluster" { transit_encryption_mode = var.transit_encryption_mode authorization_mode = var.authorization_mode node_type = var.node_type + redis_configs = var.redis_configs dynamic "psc_configs" { for_each = var.network diff --git a/modules/redis-cluster/variables.tf b/modules/redis-cluster/variables.tf index 27a6454..fd338b3 100644 --- a/modules/redis-cluster/variables.tf +++ b/modules/redis-cluster/variables.tf @@ -83,3 +83,16 @@ variable "node_type" { type = string default = null } + +variable "redis_configs" { + description = "Configure Redis Cluster behavior using a subset of native Redis configuration parameters" + type = object({ + maxmemory-clients = optional(string) + maxmemory = optional(string) + maxmemory-policy = optional(string) + notify-keyspace-events = optional(string) + slowlog-log-slower-than = optional(number) + maxclients = optional(number) + }) + default = null +} diff --git a/modules/redis-cluster/versions.tf b/modules/redis-cluster/versions.tf index 40e075f..e69f97c 100644 --- a/modules/redis-cluster/versions.tf +++ b/modules/redis-cluster/versions.tf @@ -20,11 +20,11 @@ terraform { google = { source = "hashicorp/google" - version = ">= 5.24, < 6" + version = ">= 5.28, < 6" } google-beta = { source = "hashicorp/google-beta" - version = ">= 5.24, < 6" + version = ">= 5.28, < 6" } } diff --git a/test/integration/redis-cluster/redis_cluster_test.go b/test/integration/redis-cluster/redis_cluster_test.go index 31db7a6..6ed9f17 100755 --- a/test/integration/redis-cluster/redis_cluster_test.go +++ b/test/integration/redis-cluster/redis_cluster_test.go @@ -46,6 +46,7 @@ func TestRedisCluster(t *testing.T) { assert.Equal(op.Get("replicaCount").String(), replicaCount) assert.Equal(op.Get("authorizationMode").String(), authorizationMode) assert.Equal(op.Get("nodeType").String(), nodeType) + assert.Equal(op.Get("redisConfigs.maxmemory-policy").String(), "volatile-ttl") }) rc.Test()