A Google Cloud Redis Cluster instance.
To get more information about Cluster, see:
resource "google_redis_cluster" "cluster-ha" {
name = "ha-cluster"
shard_count = 3
psc_configs {
network = google_compute_network.producer_net.id
}
region = "us-central1"
replica_count = 1
node_type = "REDIS_SHARED_CORE_NANO"
transit_encryption_mode = "TRANSIT_ENCRYPTION_MODE_DISABLED"
authorization_mode = "AUTH_MODE_DISABLED"
redis_configs = {
maxmemory-policy = "volatile-ttl"
}
depends_on = [
google_network_connectivity_service_connection_policy.default
]
lifecycle {
prevent_destroy = true
}
}
resource "google_network_connectivity_service_connection_policy" "default" {
name = "mypolicy"
location = "us-central1"
service_class = "gcp-memorystore-redis"
description = "my basic service connection policy"
network = google_compute_network.producer_net.id
psc_config {
subnetworks = [google_compute_subnetwork.producer_subnet.id]
}
}
resource "google_compute_subnetwork" "producer_subnet" {
name = "mysubnet"
ip_cidr_range = "10.0.0.248/29"
region = "us-central1"
network = google_compute_network.producer_net.id
}
resource "google_compute_network" "producer_net" {
name = "mynetwork"
auto_create_subnetworks = false
}
The following arguments are supported:
psc_configs
-
(Required)
Required. Each PscConfig configures the consumer network where two
network addresses will be designated to the cluster for client access.
Currently, only one PscConfig is supported.
Structure is documented below.
shard_count
-
(Required)
Required. Number of shards for the Redis cluster.
name
-
(Required)
Unique name of the resource in this scope including project and location using the form:
projects/{projectId}/locations/{locationId}/clusters/{clusterId}
The psc_configs
block supports:
network
-
(Required)
Required. The 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}.authorization_mode
-
(Optional)
Optional. The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster.
Default value is AUTH_MODE_DISABLED
.
Possible values are: AUTH_MODE_UNSPECIFIED
, AUTH_MODE_IAM_AUTH
, AUTH_MODE_DISABLED
.
transit_encryption_mode
-
(Optional)
Optional. The in-transit encryption for the Redis cluster.
If not provided, encryption is disabled for the cluster.
Default value is TRANSIT_ENCRYPTION_MODE_DISABLED
.
Possible values are: TRANSIT_ENCRYPTION_MODE_UNSPECIFIED
, TRANSIT_ENCRYPTION_MODE_DISABLED
, TRANSIT_ENCRYPTION_MODE_SERVER_AUTHENTICATION
.
node_type
-
(Optional)
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
.
replica_count
-
(Optional)
Optional. The number of replica nodes per shard.
redis_configs
-
(Optional)
Configure Redis Cluster behavior using a subset of native Redis configuration parameters.
Please check Memorystore documentation for the list of supported parameters:
https://cloud.google.com/memorystore/docs/cluster/supported-instance-configurations
region
-
(Optional)
The name of the region of the Redis cluster.
project
- (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
In addition to the arguments listed above, the following computed attributes are exported:
id
- an identifier for the resource with format projects/{{project}}/locations/{{region}}/clusters/{{name}}
create_time
-
The timestamp associated with the cluster creation request. A timestamp in
RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional
digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".
state
-
The current state of this cluster. Can be CREATING, READY, UPDATING, DELETING and SUSPENDED
uid
-
System assigned, unique identifier for the cluster.
discovery_endpoints
-
Output only. Endpoints created on each given network,
for Redis clients to connect to the cluster.
Currently only one endpoint is supported.
Structure is documented below.
psc_connections
-
Output only. PSC connections for discovery of the cluster topology and accessing the cluster.
Structure is documented below.
state_info
-
Output only. Additional information about the current state of the cluster.
Structure is documented below.
size_gb
-
Output only. Redis memory size in GB for the entire cluster.
precise_size_gb
-
Output only. Redis memory precise size in GB for the entire cluster.
The discovery_endpoints
block contains:
address
-
(Optional)
Output only. Network address of the exposed Redis endpoint used by clients to connect to the service.
port
-
(Optional)
Output only. The port number of the exposed Redis endpoint.
psc_config
-
(Optional)
Output only. Customer configuration for where the endpoint
is created and accessed from.
Structure is documented below.
The psc_config
block supports:
network
-
(Optional)
The consumer network where the network address of the discovery
endpoint will be reserved, in the form of
projects/{network_project_id}/global/networks/{network_id}.The psc_connections
block contains:
psc_connection_id
-
(Optional)
Output only. The PSC connection id of the forwarding rule connected to the service attachment.
address
-
(Optional)
Output only. The IP allocated on the consumer network for the PSC forwarding rule.
forwarding_rule
-
(Optional)
Output only. The URI of the consumer side forwarding rule. Example: projects/{projectNumOrId}/regions/us-east1/forwardingRules/{resourceId}.
project_id
-
(Optional)
Output only. The consumer projectId where the forwarding rule is created from.
network
-
(Optional)
The consumer network where the IP address resides, in the form of projects/{projectId}/global/networks/{network_id}.
The state_info
block contains:
update_info
-
(Optional)
A nested object resource
Structure is documented below.The update_info
block supports:
target_shard_count
-
(Optional)
Target number of shards for redis cluster.
target_replica_count
-
(Optional)
Target number of replica nodes per shard.
This resource provides the following Timeouts configuration options:
create
- Default is 60 minutes.update
- Default is 120 minutes.delete
- Default is 30 minutes.Cluster can be imported using any of these accepted formats:
projects/{{project}}/locations/{{region}}/clusters/{{name}}
{{project}}/{{region}}/{{name}}
{{region}}/{{name}}
{{name}}
In Terraform v1.5.0 and later, use an import
block to import Cluster using one of the formats above. For example:
import {
id = "projects/{{project}}/locations/{{region}}/clusters/{{name}}"
to = google_redis_cluster.default
}
When using the terraform import
command, Cluster can be imported using one of the formats above. For example:
$ terraform import google_redis_cluster.default projects/{{project}}/locations/{{region}}/clusters/{{name}}
$ terraform import google_redis_cluster.default {{project}}/{{region}}/{{name}}
$ terraform import google_redis_cluster.default {{region}}/{{name}}
$ terraform import google_redis_cluster.default {{name}}
This resource supports User Project Overrides.