Skip to content

googleRedisInstance

A Google Cloud Redis instance.

To get more information about Instance, see:

Example Usage - Redis Instance Basic

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.redisInstance.RedisInstance(this, "cache", {
  memory_size_gb: 1,
  name: "memory-cache",
});

Example Usage - Redis Instance Full

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const dataGoogleComputeNetworkRedisNetwork =
  new google.dataGoogleComputeNetwork.DataGoogleComputeNetwork(
    this,
    "redis-network",
    {
      name: "redis-test-network",
    }
  );
new google.redisInstance.RedisInstance(this, "cache", {
  alternative_location_id: "us-central1-f",
  authorized_network: dataGoogleComputeNetworkRedisNetwork.id,
  display_name: "Terraform Test Instance",
  labels: [
    {
      my_key: "my_val",
      other_key: "other_val",
    },
  ],
  location_id: "us-central1-a",
  maintenance_policy: [
    {
      weekly_maintenance_window: [
        {
          day: "TUESDAY",
          start_time: [
            {
              hours: 0,
              minutes: 30,
              nanos: 0,
              seconds: 0,
            },
          ],
        },
      ],
    },
  ],
  memory_size_gb: 1,
  name: "ha-memory-cache",
  redis_version: "REDIS_4_0",
  reserved_ip_range: "192.168.0.0/29",
  tier: "STANDARD_HA",
});

Example Usage - Redis Instance Full With Persistence Config

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.redisInstance.RedisInstance(this, "cache-persis", {
  alternative_location_id: "us-central1-f",
  location_id: "us-central1-a",
  memory_size_gb: 1,
  name: "ha-memory-cache-persis",
  persistence_config: [
    {
      persistence_mode: "RDB",
      rdb_snapshot_period: "TWELVE_HOURS",
    },
  ],
  tier: "STANDARD_HA",
});

Example Usage - Redis Instance Private Service

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const dataGoogleComputeNetworkRedisNetwork =
  new google.dataGoogleComputeNetwork.DataGoogleComputeNetwork(
    this,
    "redis-network",
    {
      name: "redis-test-network",
    }
  );
const googleComputeGlobalAddressServiceRange =
  new google.computeGlobalAddress.ComputeGlobalAddress(this, "service_range", {
    address_type: "INTERNAL",
    name: "address",
    network: dataGoogleComputeNetworkRedisNetwork.id,
    prefix_length: 16,
    purpose: "VPC_PEERING",
  });
const googleServiceNetworkingConnectionPrivateServiceConnection =
  new google.serviceNetworkingConnection.ServiceNetworkingConnection(
    this,
    "private_service_connection",
    {
      network: dataGoogleComputeNetworkRedisNetwork.id,
      reserved_peering_ranges: [googleComputeGlobalAddressServiceRange.name],
      service: "servicenetworking.googleapis.com",
    }
  );
new google.redisInstance.RedisInstance(this, "cache", {
  alternative_location_id: "us-central1-f",
  authorized_network: dataGoogleComputeNetworkRedisNetwork.id,
  connect_mode: "PRIVATE_SERVICE_ACCESS",
  depends_on: [
    `\${${googleServiceNetworkingConnectionPrivateServiceConnection.fqn}}`,
  ],
  display_name: "Terraform Test Instance",
  location_id: "us-central1-a",
  memory_size_gb: 1,
  name: "private-cache",
  redis_version: "REDIS_4_0",
  tier: "STANDARD_HA",
});

Example Usage - Redis Instance Mrr

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const dataGoogleComputeNetworkRedisNetwork =
  new google.dataGoogleComputeNetwork.DataGoogleComputeNetwork(
    this,
    "redis-network",
    {
      name: "redis-test-network",
    }
  );
new google.redisInstance.RedisInstance(this, "cache", {
  alternative_location_id: "us-central1-f",
  authorized_network: dataGoogleComputeNetworkRedisNetwork.id,
  display_name: "Terraform Test Instance",
  labels: [
    {
      my_key: "my_val",
      other_key: "other_val",
    },
  ],
  location_id: "us-central1-a",
  memory_size_gb: 5,
  name: "mrr-memory-cache",
  read_replicas_mode: "READ_REPLICAS_ENABLED",
  redis_version: "REDIS_6_X",
  replica_count: 5,
  reserved_ip_range: "192.168.0.0/28",
  tier: "STANDARD_HA",
});

Example Usage - Redis Instance Cmek

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleKmsKeyRingRedisKeyring = new google.kmsKeyRing.KmsKeyRing(
  this,
  "redis_keyring",
  {
    location: "us-central1",
    name: "redis-keyring",
  }
);
const dataGoogleComputeNetworkRedisNetwork =
  new google.dataGoogleComputeNetwork.DataGoogleComputeNetwork(
    this,
    "redis-network",
    {
      name: "redis-test-network",
    }
  );
const googleKmsCryptoKeyRedisKey = new google.kmsCryptoKey.KmsCryptoKey(
  this,
  "redis_key",
  {
    key_ring: googleKmsKeyRingRedisKeyring.id,
    name: "redis-key",
  }
);
new google.redisInstance.RedisInstance(this, "cache", {
  alternative_location_id: "us-central1-f",
  authorized_network: dataGoogleComputeNetworkRedisNetwork.id,
  customer_managed_key: googleKmsCryptoKeyRedisKey.id,
  display_name: "Terraform Test Instance",
  labels: [
    {
      my_key: "my_val",
      other_key: "other_val",
    },
  ],
  location_id: "us-central1-a",
  memory_size_gb: 1,
  name: "cmek-memory-cache",
  redis_version: "REDIS_6_X",
  reserved_ip_range: "192.168.0.0/29",
  tier: "STANDARD_HA",
});

Argument Reference

The following arguments are supported:

  • name - (Required) The ID of the instance or a fully qualified identifier for the instance.

  • memorySizeGb - (Required) Redis memory size in GiB.


  • alternativeLocationId - (Optional) 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].

  • authEnabled - (Optional) 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.

  • authorizedNetwork - (Optional) The full name of the Google Compute Engine network to which the instance is connected. If left unspecified, the default network will be used.

  • connectMode - (Optional) The connection mode of the Redis instance. Default value is directPeering. Possible values are directPeering and privateServiceAccess.

  • displayName - (Optional) An arbitrary and optional user-provided name for the instance.

  • labels - (Optional) Resource labels to represent user provided metadata.

  • redisConfigs - (Optional) 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

  • locationId - (Optional) 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].

  • persistenceConfig - (Optional) Persistence configuration for an instance. Structure is documented below.

  • maintenancePolicy - (Optional) Maintenance policy for an instance. Structure is documented below.

  • maintenanceSchedule - (Optional) Upcoming maintenance schedule. Structure is documented below.

  • redisVersion - (Optional) The version of Redis software. If not provided, latest supported version will be used. Please check the API documentation linked at the top for the latest valid values.

  • reservedIpRange - (Optional) 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) The service tier of the instance. Must be one of these values:

    • BASIC: standalone instance
    • STANDARD_HA: highly available primary/replica instances Default value is basic. Possible values are basic and standardHa.
  • transitEncryptionMode - (Optional) The TLS mode of the Redis instance, If not provided, TLS is disabled for the instance.

    • SERVER_AUTHENTICATION: Client to Server traffic encryption enabled with server authentication Default value is disabled. Possible values are serverAuthentication and disabled.
  • replicaCount - (Optional) Optional. The number of replica nodes. The valid range for the Standard Tier with read replicas enabled is [1-5] and defaults to 2. If read replicas are not enabled for a Standard Tier instance, the only valid value is 1 and the default is 1. The valid value for basic tier is 0 and the default is also 0.

  • readReplicasMode - (Optional) Optional. Read replica mode. Can only be specified when trying to create the instance. If not set, Memorystore Redis backend will default to READ_REPLICAS_DISABLED.

    • READ_REPLICAS_DISABLED: If disabled, read endpoint will not be provided and the instance cannot scale up or down the number of replicas.
    • READ_REPLICAS_ENABLED: If enabled, read endpoint will be provided and the instance can scale up and down the number of replicas. Possible values are readReplicasDisabled and readReplicasEnabled.
  • secondaryIpRange - (Optional) Optional. Additional IP range for node placement. Required when enabling read replicas on an existing instance. For DIRECT_PEERING mode value must be a CIDR range of size /28, or "auto". For PRIVATE_SERVICE_ACCESS mode value must be the name of an allocated address range associated with the private service access connection, or "auto".

  • customerManagedKey - (Optional) Optional. The KMS key reference that you want to use to encrypt the data at rest for this Redis instance. If this is provided, CMEK is enabled.

  • region - (Optional) The name of the Redis region of the instance.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

The persistenceConfig block supports:

  • persistenceMode - (Required) Optional. Controls whether Persistence features are enabled. If not provided, the existing value will be used.

    • DISABLED: Persistence is disabled for the instance, and any existing snapshots are deleted.
    • RDB: RDB based Persistence is enabled. Possible values are disabled and rdb.
  • rdbSnapshotPeriod - (Optional) Optional. Available snapshot periods for scheduling.

    • ONE_HOUR: Snapshot every 1 hour.
    • SIX_HOURS: Snapshot every 6 hours.
    • TWELVE_HOURS: Snapshot every 12 hours.
    • TWENTY_FOUR_HOURS: Snapshot every 24 hours. Possible values are oneHour, sixHours, twelveHours, and twentyFourHours.
  • rdbNextSnapshotTime - (Output) Output only. The next time that a snapshot attempt is scheduled to occur. 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".

  • rdbSnapshotStartTime - (Optional) Optional. Date and time that the first snapshot was/will be attempted, and to which future snapshots will be aligned. If not provided, the current time will be used. 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".

The maintenancePolicy block supports:

  • createTime - (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.

  • updateTime - (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.

  • description - (Optional) Optional. Description of what this policy is for. Create/Update methods return INVALID_ARGUMENT if the length is greater than 512.

  • weeklyMaintenanceWindow - (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.

The weeklyMaintenanceWindow 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 dayOfWeekUnspecified, monday, tuesday, wednesday, thursday, friday, saturday, and 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".

  • startTime - (Required) Required. Start time of the window in UTC time. Structure is documented below.

The startTime 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.

The maintenanceSchedule block supports:

  • startTime - (Output) Output only. The start time of any upcoming scheduled maintenance for this instance. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.

  • endTime - (Output) Output only. The end time of any upcoming scheduled maintenance for this instance. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.

  • scheduleDeadlineTime - (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.

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}}/instances/{{name}}

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

  • currentLocationId - 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.

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

  • port - The port number of the exposed Redis endpoint.

  • persistenceIamIdentity - 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.

  • serverCaCerts - List of server CA certificates for the instance. Structure is documented below.

  • nodes - Output only. Info per node. Structure is documented below.

  • readEndpoint - Output only. Hostname or IP address of the exposed readonly Redis endpoint. Standard tier only. Targets all healthy replica nodes in instance. Replication is asynchronous and replica nodes will exhibit some lag behind the primary. Write requests must target 'host'.

  • readEndpointPort - Output only. The port number of the exposed readonly redis endpoint. Standard tier only. Write requests should target 'port'.

The serverCaCerts block contains:

  • serialNumber - (Output) Serial number, as extracted from the certificate.

  • cert - (Output) The certificate data in PEM format.

  • createTime - (Output) The time when the certificate was created.

  • expireTime - (Output) The time when the certificate expires.

  • sha1Fingerprint - (Output) Sha1 Fingerprint of the certificate.

The nodes block contains:

  • id - (Output) Node identifying string. e.g. 'node-0', 'node-1'

  • zone - (Output) Location of the node.

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 20 minutes.
  • update - Default is 20 minutes.
  • delete - Default is 20 minutes.

Import

Instance can be imported using any of these accepted formats:

$ terraform import google_redis_instance.default projects/{{project}}/locations/{{region}}/instances/{{name}}
$ terraform import google_redis_instance.default {{project}}/{{region}}/{{name}}
$ terraform import google_redis_instance.default {{region}}/{{name}}
$ terraform import google_redis_instance.default {{name}}

User Project Overrides

This resource supports User Project Overrides.