Skip to content

Commit

Permalink
feat(TPG>5.28)!: add redis_configs in redis cluster (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
imrannayer authored May 13, 2024
1 parent 2f47eb5 commit 30d5433
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 23 deletions.
5 changes: 3 additions & 2 deletions docs/upgrading_to_v9.0.md
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 12 additions & 6 deletions examples/redis-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -33,5 +34,10 @@ module "redis_cluster" {
]
}
}

redis_configs = {
maxmemory-policy = "volatile-ttl"
}

depends_on = [module.test_vpc]
}
22 changes: 9 additions & 13 deletions modules/redis-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
```

Expand All @@ -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 | <pre>object({<br> maxmemory-clients = optional(string)<br> maxmemory = optional(string)<br> maxmemory-policy = optional(string)<br> notify-keyspace-events = optional(string)<br> slowlog-log-slower-than = optional(number)<br> maxclients = optional(number)<br> })</pre> | `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 | <pre>map(object({<br> description = optional(string)<br> network_name = string<br> network_project = string<br> subnet_names = list(string)<br> limit = optional(number)<br> labels = optional(map(string), {})<br> }))</pre> | `{}` | no |
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions modules/redis-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions modules/redis-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions modules/redis-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

Expand Down
1 change: 1 addition & 0 deletions test/integration/redis-cluster/redis_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 30d5433

Please sign in to comment.