This page lists the gcloud CLI commands needed to set up
prerequisites, provision an instance, describe an instance, and delete an
instance on a standard VPC network. For instructions on performing these tasks
on a Shared VPC network, see [Instance provisioning on a Shared VPC network](https://docs.cloud.google.com/memorystore/docs/cluster/instance-provisioning-shared-vpc.md.txt). In order to accomplish these
tasks you should follow the instructions in each section of this page.

For more detailed guidance for these tasks, see the following pages:

- [Networking](https://docs.cloud.google.com/memorystore/docs/cluster/networking.md.txt)
- [Create instances](https://docs.cloud.google.com/memorystore/docs/cluster/create-instances.md.txt)
- [List instances](https://docs.cloud.google.com/memorystore/docs/cluster/list-instances.md.txt)
- [Delete clusters](https://docs.cloud.google.com/memorystore/docs/cluster/delete-instances.md.txt)

## Enable APIs

Begin by enabling the APIs in this section. These APIs are needed because
Memorystore for Redis Cluster uses Private Service Connect service
connectivity automation to automate connectivity for instances. For more
information, see [Networking](https://docs.cloud.google.com/memorystore/docs/cluster/networking.md.txt).

To enable the APIs, run the following commands:

### gcloud

```
gcloud services enable --project=PROJECT_ID networkconnectivity.googleapis.com
gcloud services enable --project=PROJECT_ID compute.googleapis.com
gcloud services enable --project=PROJECT_ID serviceconsumermanagement.googleapis.com
gcloud services enable --project=PROJECT_ID redis.googleapis.com
```

Replace the following:

- <var translate="no">PROJECT_ID</var> is your project ID.

## Create a service connection policy

You must create a [service connection policy](https://docs.cloud.google.com/vpc/docs/about-service-connection-policies.md.txt)
for the project, network, and region where you want to provision the
Memorystore for Redis Cluster instance. A service connection policy lets you authorize
the `gcp-memorystore-redis` service class to create a Private Service Connect
connection between producer and consumer VPC networks in the region where the
policy is defined, and in the subnets that the policy specifies.

To see the permission needed to create a service connection policy, see [required roles](https://docs.cloud.google.com/vpc/docs/configure-service-connection-policies.md.txt#roles).

This walkthrough uses the `default` network and `default` subnet.

To create the service connection policy, run the following command:

### gcloud

```
gcloud network-connectivity service-connection-policies create POLICY_NAME \
  --network=default \
  --project=PROJECT_ID \
  --region=REGION \
  --service-class=gcp-memorystore-redis \
  --subnets=https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/subnetworks/default
```

Replace the following:

- <var translate="no">POLICY_NAME</var> is your desired policy name.
- <var translate="no">PROJECT_ID</var> is the project ID.
- <var translate="no">REGION</var> is the same region where you want to provision your Memorystore for Redis Cluster instance.

## Validate the creation of the service connection policy

Validate if the policy was created successfully by running the `list` command:

### gcloud

```
gcloud network-connectivity service-connection-policies list --region=REGION --project=PROJECT_ID
```

Replace the following:

- <var translate="no">PROJECT_ID</var> is the project ID.
- <var translate="no">REGION</var> is the region where the service connection policy is defined.

## Create an instance

To create an instance, run the `create` command:

### gcloud

```
gcloud redis clusters create INSTANCE_ID \
--project=PROJECT_ID \
--region=REGION \
--node-type=NODE_TYPE \
--shard-count=SHARD_COUNT \
--replica-count=REPLICA_COUNT \
--network=projects/PROJECT_ID/global/networks/default
```

Replace the following:

- <var translate="no">INSTANCE_ID</var> is the instance ID.
- <var translate="no">PROJECT_ID</var> is the project ID.
- <var translate="no">REGION</var> is the region where you want to provision your instance.

- <var translate="no">NODE_TYPE</var> is the [node type](https://docs.cloud.google.com/memorystore/docs/cluster/cluster-node-specification.md.txt#choose_a_node_type) that you want to use for the
  cluster.

  > [!CAUTION]
  > **Caution** : We recommend that you use the `redis-shared-core-nano` node type only for development or testing purposes because this node type has no SLA. If you run Memorystore for Redis Cluster in a production environment, then we recommend using another node type.

- <var translate="no">SHARD_COUNT</var> determines the number of shards in your
  instance. Shard count determines the total memory capacity for storing
  cluster data. To see more details about cluster specification, see [Cluster and node specification](https://docs.cloud.google.com/memorystore/docs/cluster/cluster-node-specification.md.txt).

- <var translate="no">REPLICA_COUNT</var> is the number of read replicas (per shard).
  Accepted values are `0`-`5`.

> [!NOTE]
> **Note:** When running the `create` command you must use the same network and same region where the service connection policy is defined.

## Describe the instance

To view instance details, run the `describe` command:

### gcloud

```
gcloud redis clusters describe INSTANCE_ID \
--project=PROJECT_ID \
--region=REGION
```

Replace the following:

- <var translate="no">INSTANCE_ID</var> is the instance ID.
- <var translate="no">PROJECT_ID</var> is the project ID.
- <var translate="no">REGION</var> is the region where your instance is located.

## Delete the instance

To delete an instance, run the `delete` command:

### gcloud

```
gcloud redis clusters delete INSTANCE_ID \
--project=PROJECT_ID \
--region=REGION
```

Replace the following:

- <var translate="no">INSTANCE_ID</var> is the instance ID.
- <var translate="no">PROJECT_ID</var> is the project ID.
- <var translate="no">REGION</var> is the region where your instance is located.