|
| 1 | +# Memorystore Valkey Terraform Module |
| 2 | + |
| 3 | +A Terraform module for creating Google [Memorystore for Valkey](https://cloud.google.com/memorystore/docs/valkey/product-overview). It can also create [service connection policies](https://cloud.google.com/vpc/docs/about-service-connection-policies). You can also create service connection policy outside of this module. If you are not creating service connection policy as part of this module then make sure they exist before creating valkey cluster. You can find more details [here](https://cloud.google.com/memorystore/docs/valkey/networking) |
| 4 | + |
| 5 | +## Compatibility |
| 6 | +This module is meant for use with Terraform 1.3+ and tested using Terraform 1.3+. If you find incompatibilities using Terraform >=1.3, please open an issue. |
| 7 | + |
| 8 | +## Usage |
| 9 | + |
| 10 | +``` |
| 11 | +module "valkey_cluster" { |
| 12 | + source = "terraform-google-modules/memorystore/google//modules/valkey" |
| 13 | + version = "~> 11.0" |
| 14 | +
|
| 15 | + instance_id = "test-valkey-cluster" |
| 16 | + project = var.project_id |
| 17 | + location = "us-central1" |
| 18 | + node_type = "HIGHMEM_MEDIUM" |
| 19 | + deletion_protection_enabled = false |
| 20 | + engine_version = "VALKEY_8_0" |
| 21 | +
|
| 22 | + network = "valkey-network" |
| 23 | +
|
| 24 | + service_connection_policies = { |
| 25 | + test-net-valkey-cluster-scp = { |
| 26 | + subnet_names = [ |
| 27 | + "valkey-subnet-100", |
| 28 | + "valkey-subnet-101", |
| 29 | + ] |
| 30 | + } |
| 31 | + } |
| 32 | +
|
| 33 | + engine_configs = { |
| 34 | + maxmemory-policy = "volatile-ttl" |
| 35 | + } |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 40 | +## Inputs |
| 41 | + |
| 42 | +| Name | Description | Type | Default | Required | |
| 43 | +|------|-------------|------|---------|:--------:| |
| 44 | +| authorization\_mode | The Immutable. Authorization mode of the instance. Possible values: AUTH\_DISABLED IAM\_AUTH | `string` | `"AUTH_DISABLED"` | no | |
| 45 | +| deletion\_protection\_enabled | If set to true deletion of the instance will fail | `bool` | `true` | no | |
| 46 | +| enable\_apis | Flag for enabling memcache.googleapis.com in your project | `bool` | `false` | no | |
| 47 | +| engine\_configs | User-provided engine configurations for the instance | <pre>object({<br> maxmemory = optional(string)<br> maxmemory-clients = 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 | |
| 48 | +| engine\_version | Immutable. Engine version of the instance | `string` | `"VALKEY_8_0"` | no | |
| 49 | +| instance\_id | The ID to use for the instance, which will become the final component of the instance's resource name. Must be 4-63 characters in length with lowercase letters, digits, and hyphens. Must not end with a hyphen. Must be unique within a location | `string` | n/a | yes | |
| 50 | +| labels | The resource labels to represent user provided metadata. | `map(string)` | `{}` | no | |
| 51 | +| location | The region where valkey cluster will be created | `string` | n/a | yes | |
| 52 | +| network | Name of the consumer network where the network address of the discovery endpoint will be reserved | `string` | n/a | yes | |
| 53 | +| network\_project | project ID of the consumer network where the network address of the discovery endpoint will be reserved. Required for Shared VPC host | `string` | `null` | no | |
| 54 | +| node\_type | The nodeType for the valkey cluster. Possible values are: SHARED\_CORE\_NANO, HIGHMEM\_MEDIUM, HIGHMEM\_XLARGE, STANDARD\_SMALL | `string` | `null` | no | |
| 55 | +| persistence\_config | User-provided persistence configurations for the instance | <pre>object({<br> mode = optional(string)<br> rdb_config = optional(object({<br> rdb_snapshot_period = optional(string)<br> rdb_snapshot_start_time = optional(string)<br> }), null)<br> aof_config = optional(object({<br> append_fsync = string<br> }), null)<br> })</pre> | `{}` | no | |
| 56 | +| project | The ID of the project in which the resource belongs to. | `string` | n/a | yes | |
| 57 | +| replica\_count | Number of replica nodes per shard. If omitted the default is 0 replicas | `number` | `0` | no | |
| 58 | +| service\_connection\_policies | The Service Connection Policies to create. Required to create service connection policy. Not needed if service connection policy already exist | <pre>map(object({<br> subnet_names = list(string)<br> description = optional(string)<br> limit = optional(number)<br> labels = optional(map(string), {})<br> }))</pre> | `{}` | no | |
| 59 | +| shard\_count | Number of shards for the instance | `number` | `3` | no | |
| 60 | +| transit\_encryption\_mode | Immutable. In-transit encryption mode of the instance. Possible values: TRANSIT\_ENCRYPTION\_DISABLED SERVER\_AUTHENTICATION | `string` | `"TRANSIT_ENCRYPTION_DISABLED"` | no | |
| 61 | +| zone\_distribution\_config\_mode | The mode for zone distribution for Memorystore valkey cluster (Immutable). If not provided, MULTI\_ZONE will be used as default value. Possible values are: MULTI\_ZONE, SINGLE\_ZONE | `string` | `"MULTI_ZONE"` | no | |
| 62 | +| zone\_distribution\_config\_zone | The zone for single zone Memorystore valkey cluster (Immutable) | `string` | `null` | no | |
| 63 | + |
| 64 | +## Outputs |
| 65 | + |
| 66 | +| Name | Description | |
| 67 | +|------|-------------| |
| 68 | +| discovery\_endpoints | Endpoints created on each given network, for valkey clients to connect to the cluster. Currently only one endpoint is supported | |
| 69 | +| id | The valkey cluster instance ID | |
| 70 | +| psc\_connections | PSC connections for discovery of the cluster topology and accessing the cluster | |
| 71 | +| valkey\_cluster | The valkey cluster created | |
| 72 | + |
| 73 | +<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 74 | + |
| 75 | +## Requirements |
| 76 | + |
| 77 | +These sections describe requirements for using this module. |
| 78 | + |
| 79 | +### Software |
| 80 | + |
| 81 | +The following dependencies must be available: |
| 82 | + |
| 83 | +- [Terraform][terraform] v1.3+ |
| 84 | +- [Terraform Provider for GCP][terraform-provider-gcp] plugin v6.3+ |
| 85 | + |
| 86 | +### Service Account |
| 87 | + |
| 88 | +Following roles contain permissions to deploy resource. |
| 89 | + |
| 90 | +- Cloud Memorystore valkey Admin: `roles/memorystore.admin` |
| 91 | +- Compute Network Admin: `roles/compute.networkAdmin` |
| 92 | + |
| 93 | +### Enable API's |
| 94 | +In order to operate with the Service Account you must activate the following API on the project where the Service Account was created: |
| 95 | + |
| 96 | +- Memorystore for valkey API - `memorystore.googleapis.com` |
| 97 | +- Service Consumer Management API - `serviceconsumermanagement.googleapis.com` |
| 98 | +- Network Connectivity API - `networkconnectivity.googleapis.com` |
| 99 | +- Compute Engine API - `compute.googleapis.com` |
| 100 | + |
0 commit comments