Google Memorystore (Redis) Instance

This page shows how to write Terraform for Memorystore (Redis) Instance and write them securely.

google_redis_instance (Terraform)

The Instance in Memorystore (Redis) can be configured in Terraform with the resource name google_redis_instance. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

redis_instance_test.tf#L6
resource "google_redis_instance" "basic_m1" {
  name           = "memory-cache"
  memory_size_gb = 1
}

resource "google_redis_instance" "basic_m2" {
redis_instance_test.tf#L6
resource "google_redis_instance" "basic_m1" {
  name           = "memory-cache"
  memory_size_gb = 1
}

resource "google_redis_instance" "basic_m2" {
redis.tf#L1
resource "google_redis_instance" "cache" {
  name           = "memory-cache"
  memory_size_gb = 1
main.tf#L1
resource "google_redis_instance" "cache" {
  authorized_network = var.network
  display_name       = var.display_name
  name               = var.name
  memory_size_gb     = var.size
  location_id        = var.location
main.tf#L1
resource "google_redis_instance" "redis_instance" {
  name               = var.redis_instance_name
  memory_size_gb     = var.redis_instance_size
  authorized_network = var.redis_instance_network
  tier               = "BASIC"
  location_id        = var.redis_instance_region_zone

Review your Terraform file for Google best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Only applicable to STANDARD_HA tier which protects the instance against zonal failures by provisioning it across two zones. If provided, it must be a different zone from the one provided in [locationId].

Optional. Indicates whether OSS Redis AUTH is enabled for the instance. If set to "true" AUTH is enabled on the instance. Default value is "false" meaning AUTH is disabled.

AUTH String set on the instance. This field will only be populated if auth_enabled is true.

The full name of the Google Compute Engine network to which the instance is connected. If left unspecified, the default network will be used.

The connection mode of the Redis instance. Default value: "DIRECT_PEERING" Possible values: ["DIRECT_PEERING", "PRIVATE_SERVICE_ACCESS"]

The time the instance was created in RFC3339 UTC "Zulu" format, accurate to nanoseconds.

The current zone where the Redis endpoint is placed. For Basic Tier instances, this will always be the same as the [locationId] provided by the user at creation time. For Standard Tier instances, this can be either [locationId] or [alternativeLocationId] and can change after a failover event.

An arbitrary and optional user-provided name for the instance.

  • host optional computed - string

Hostname or IP address of the exposed Redis endpoint used by clients to connect to the service.

  • id optional computed - string
  • labels optional - map from string to string

Resource labels to represent user provided metadata.

The zone where the instance will be provisioned. If not provided, the service will choose a zone for the instance. For STANDARD_HA tier, instances will be created across two zones for protection against zonal failures. If [alternativeLocationId] is also provided, it must be different from [locationId].

Redis memory size in GiB.

The ID of the instance or a fully qualified identifier for the instance.

Output only. Cloud IAM identity used by import / export operations to transfer data to/from Cloud Storage. Format is "serviceAccount:". The value may change over time for a given instance so should be checked before each import/export operation.

  • port optional computed - number

The port number of the exposed Redis endpoint.

Redis configuration parameters, according to http://redis.io/topics/config. Please check Memorystore documentation for the list of supported parameters: https://cloud.google.com/memorystore/docs/redis/reference/rest/v1/projects.locations.instances#Instance.FIELDS.redis_configs

The version of Redis software. If not provided, latest supported version will be used. Currently, the supported values are: - REDIS_5_0 for Redis 5.0 compatibility - REDIS_4_0 for Redis 4.0 compatibility - REDIS_3_2 for Redis 3.2 compatibility

  • region optional computed - string

The name of the Redis region of the instance.

The CIDR range of internal addresses that are reserved for this instance. If not provided, the service will choose an unused /29 block, for example, 10.0.0.0/29 or 192.168.0.0/29. Ranges must be unique and non-overlapping with existing subnets in an authorized network.

The service tier of the instance. Must be one of these values: - BASIC: standalone instance - STANDARD_HA: highly available primary/replica instances Default value: "BASIC" Possible values: ["BASIC", "STANDARD_HA"]

Explanation in Terraform Registry

A Google Cloud Redis instance. To get more information about Instance, see:

Frequently asked questions

What is Google Memorystore (Redis) Instance?

Google Memorystore (Redis) Instance is a resource for Memorystore (Redis) of Google Cloud Platform. Settings can be wrote in Terraform.

Where can I find the example code for the Google Memorystore (Redis) Instance?

For Terraform, the infracost/infracost, gilyas/infracost and Patryk7975/test source code examples are useful. See the Terraform Example section for further details.

security-icon

Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.