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
resource "google_redis_instance" "basic_m1" {
name = "memory-cache"
memory_size_gb = 1
}
resource "google_redis_instance" "basic_m2" {
resource "google_redis_instance" "basic_m1" {
name = "memory-cache"
memory_size_gb = 1
}
resource "google_redis_instance" "basic_m2" {
resource "google_redis_instance" "cache" {
name = "memory-cache"
memory_size_gb = 1
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
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
Parameters
-
alternative_location_id
optional computed - string
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].
-
auth_enabled
optional - bool
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
optional computed - string
AUTH String set on the instance. This field will only be populated if auth_enabled is true.
-
authorized_network
optional computed - string
The full name of the Google Compute Engine network to which the instance is connected. If left unspecified, the default network will be used.
-
connect_mode
optional - string
The connection mode of the Redis instance. Default value: "DIRECT_PEERING" Possible values: ["DIRECT_PEERING", "PRIVATE_SERVICE_ACCESS"]
-
create_time
optional computed - string
The time the instance was created in RFC3339 UTC "Zulu" format, accurate to nanoseconds.
-
current_location_id
optional computed - string
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.
-
display_name
optional - string
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.
Resource labels to represent user provided metadata.
-
location_id
optional computed - string
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].
-
memory_size_gb
required - number
Redis memory size in GiB.
-
name
required - string
The ID of the instance or a fully qualified identifier for the instance.
-
persistence_iam_identity
optional computed - string
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.
-
project
optional computed - string -
redis_configs
optional - map from string to string
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
-
redis_version
optional computed - string
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.
-
reserved_ip_range
optional computed - string
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.
-
tier
optional - string
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:
- API documentation
- How-to Guides
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.