| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** AUTO GENERATED CODE *** Type: MMv1 *** |
| # |
| # ---------------------------------------------------------------------------- |
| # |
| # This file is automatically generated by Magic Modules and manual |
| # changes will be clobbered when the file is regenerated. |
| # |
| # Please read more about how to change this file in |
| # .github/CONTRIBUTING.md. |
| # |
| # ---------------------------------------------------------------------------- |
| subcategory: "Memorystore (Redis)" |
| description: |- |
| A Google Cloud Redis Cluster instance. |
| --- |
| |
| # google_redis_cluster |
| |
| A Google Cloud Redis Cluster instance. |
| |
| |
| To get more information about Cluster, see: |
| |
| * [API documentation](https://cloud.google.com/memorystore/docs/cluster/reference/rest/v1/projects.locations.clusters) |
| * How-to Guides |
| * [Official Documentation](https://cloud.google.com/memorystore/docs/cluster/) |
| |
| <div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=redis_cluster_ha&open_in_editor=main.tf" target="_blank"> |
| <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| </a> |
| </div> |
| ## Example Usage - Redis Cluster Ha |
| |
| |
| ```hcl |
| 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" |
| } |
| deletion_protection_enabled = true |
| |
| zone_distribution_config { |
| mode = "MULTI_ZONE" |
| } |
| maintenance_policy { |
| weekly_maintenance_window { |
| day = "MONDAY" |
| start_time { |
| hours = 1 |
| minutes = 0 |
| seconds = 0 |
| nanos = 0 |
| } |
| } |
| } |
| depends_on = [ |
| google_network_connectivity_service_connection_policy.default |
| ] |
| } |
| |
| 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 |
| } |
| ``` |
| <div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=redis_cluster_ha_single_zone&open_in_editor=main.tf" target="_blank"> |
| <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| </a> |
| </div> |
| ## Example Usage - Redis Cluster Ha Single Zone |
| |
| |
| ```hcl |
| resource "google_redis_cluster" "cluster-ha-single-zone" { |
| name = "ha-cluster-single-zone" |
| shard_count = 3 |
| psc_configs { |
| network = google_compute_network.producer_net.id |
| } |
| region = "us-central1" |
| zone_distribution_config { |
| mode = "SINGLE_ZONE" |
| zone = "us-central1-f" |
| } |
| maintenance_policy { |
| weekly_maintenance_window { |
| day = "MONDAY" |
| start_time { |
| hours = 1 |
| minutes = 0 |
| seconds = 0 |
| nanos = 0 |
| } |
| } |
| } |
| deletion_protection_enabled = true |
| depends_on = [ |
| google_network_connectivity_service_connection_policy.default |
| ] |
| |
| } |
| |
| 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 |
| } |
| ``` |
| |
| ## Argument Reference |
| |
| 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](#nested_psc_configs). |
| |
| * `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} |
| |
| |
| <a name="nested_psc_configs"></a>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`. |
| |
| * `zone_distribution_config` - |
| (Optional) |
| Immutable. Zone distribution config for Memorystore Redis cluster. |
| Structure is [documented below](#nested_zone_distribution_config). |
| |
| * `replica_count` - |
| (Optional) |
| Optional. The number of replica nodes per shard. |
| |
| * `deletion_protection_enabled` - |
| (Optional) |
| Optional. Indicates if the cluster is deletion protected or not. |
| If the value if set to true, any delete cluster operation will fail. |
| Default value is true. |
| |
| * `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 |
| |
| * `maintenance_policy` - |
| (Optional) |
| Maintenance policy for a cluster |
| Structure is [documented below](#nested_maintenance_policy). |
| |
| * `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. |
| |
| |
| <a name="nested_zone_distribution_config"></a>The `zone_distribution_config` block supports: |
| |
| * `mode` - |
| (Optional) |
| Immutable. The mode for zone distribution for Memorystore Redis cluster. |
| If not provided, MULTI_ZONE will be used as default |
| Possible values are: `MULTI_ZONE`, `SINGLE_ZONE`. |
| |
| * `zone` - |
| (Optional) |
| Immutable. The zone for single zone Memorystore Redis cluster. |
| |
| <a name="nested_maintenance_policy"></a>The `maintenance_policy` block supports: |
| |
| * `create_time` - |
| (Output) |
| Output only. The time when the policy was created. |
| A timestamp in RFC3339 UTC "Zulu" format, with nanosecond |
| resolution and up to nine fractional digits. |
| |
| * `update_time` - |
| (Output) |
| Output only. The time when the policy was last updated. |
| A timestamp in RFC3339 UTC "Zulu" format, with nanosecond |
| resolution and up to nine fractional digits. |
| |
| * `weekly_maintenance_window` - |
| (Optional) |
| Optional. Maintenance window that is applied to resources covered by this policy. |
| Minimum 1. For the current version, the maximum number |
| of weekly_window is expected to be one. |
| Structure is [documented below](#nested_weekly_maintenance_window). |
| |
| |
| <a name="nested_weekly_maintenance_window"></a>The `weekly_maintenance_window` block supports: |
| |
| * `day` - |
| (Required) |
| Required. The day of week that maintenance updates occur. |
| - DAY_OF_WEEK_UNSPECIFIED: The day of the week is unspecified. |
| - MONDAY: Monday |
| - TUESDAY: Tuesday |
| - WEDNESDAY: Wednesday |
| - THURSDAY: Thursday |
| - FRIDAY: Friday |
| - SATURDAY: Saturday |
| - SUNDAY: Sunday |
| Possible values are: `DAY_OF_WEEK_UNSPECIFIED`, `MONDAY`, `TUESDAY`, `WEDNESDAY`, `THURSDAY`, `FRIDAY`, `SATURDAY`, `SUNDAY`. |
| |
| * `duration` - |
| (Output) |
| Output only. Duration of the maintenance window. |
| The current window is fixed at 1 hour. |
| A duration in seconds with up to nine fractional digits, |
| terminated by 's'. Example: "3.5s". |
| |
| * `start_time` - |
| (Required) |
| Required. Start time of the window in UTC time. |
| Structure is [documented below](#nested_start_time). |
| |
| |
| <a name="nested_start_time"></a>The `start_time` block supports: |
| |
| * `hours` - |
| (Optional) |
| Hours of day in 24 hour format. Should be from 0 to 23. |
| An API may choose to allow the value "24:00:00" for scenarios like business closing time. |
| |
| * `minutes` - |
| (Optional) |
| Minutes of hour of day. Must be from 0 to 59. |
| |
| * `seconds` - |
| (Optional) |
| Seconds of minutes of the time. Must normally be from 0 to 59. |
| An API may allow the value 60 if it allows leap-seconds. |
| |
| * `nanos` - |
| (Optional) |
| Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999. |
| |
| ## Attributes Reference |
| |
| 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](#nested_discovery_endpoints). |
| |
| * `psc_connections` - |
| Output only. PSC connections for discovery of the cluster topology and accessing the cluster. |
| Structure is [documented below](#nested_psc_connections). |
| |
| * `state_info` - |
| Output only. Additional information about the current state of the cluster. |
| Structure is [documented below](#nested_state_info). |
| |
| * `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. |
| |
| * `maintenance_schedule` - |
| Upcoming maintenance schedule. |
| Structure is [documented below](#nested_maintenance_schedule). |
| |
| |
| <a name="nested_discovery_endpoints"></a>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](#nested_psc_config). |
| |
| |
| <a name="nested_psc_config"></a>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}. |
| |
| <a name="nested_psc_connections"></a>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}. |
| |
| <a name="nested_state_info"></a>The `state_info` block contains: |
| |
| * `update_info` - |
| (Optional) |
| A nested object resource |
| Structure is [documented below](#nested_update_info). |
| |
| |
| <a name="nested_update_info"></a>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. |
| |
| <a name="nested_maintenance_schedule"></a>The `maintenance_schedule` block contains: |
| |
| * `start_time` - |
| (Output) |
| Output only. The start time of any upcoming scheduled maintenance for this cluster. |
| A timestamp in RFC3339 UTC "Zulu" format, with nanosecond |
| resolution and up to nine fractional digits. |
| |
| * `end_time` - |
| (Output) |
| Output only. The end time of any upcoming scheduled maintenance for this cluster. |
| A timestamp in RFC3339 UTC "Zulu" format, with nanosecond |
| resolution and up to nine fractional digits. |
| |
| * `schedule_deadline_time` - |
| (Output) |
| Output only. The deadline that the maintenance schedule start time |
| can not go beyond, including reschedule. |
| A timestamp in RFC3339 UTC "Zulu" format, with nanosecond |
| resolution and up to nine fractional digits. |
| |
| ## Timeouts |
| |
| This resource provides the following |
| [Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: |
| |
| - `create` - Default is 60 minutes. |
| - `update` - Default is 120 minutes. |
| - `delete` - Default is 30 minutes. |
| |
| ## Import |
| |
| |
| 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](https://developer.hashicorp.com/terraform/language/import) to import Cluster using one of the formats above. For example: |
| |
| ```tf |
| import { |
| id = "projects/{{project}}/locations/{{region}}/clusters/{{name}}" |
| to = google_redis_cluster.default |
| } |
| ``` |
| |
| When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), 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}} |
| ``` |
| |
| ## User Project Overrides |
| |
| This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). |