Instance provisioning on a VPC network

This page lists the gcloud CLI commands needed to set upprerequisites, provision an instance, describe an instance, and delete aninstance on a standard VPC network. For instructions on performing these taskson a Shared VPC network, seeInstance provisioning on a Shared VPC network. In order to accomplish thesetasks you should follow the instructions in each section of this page.

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

Enable APIs

Begin by enabling the APIs in this section. These APIs are needed becauseMemorystore for Valkey uses Private Service Connect serviceconnectivity automation to automate connectivity for instances. For moreinformation, seeNetworking.

To enable the APIs, run the following commands:

gcloud

gcloud services enable --project=PROJECT_ID networkconnectivity.googleapis.comgcloud services enable --project=PROJECT_ID compute.googleapis.comgcloud services enable --project=PROJECT_ID serviceconsumermanagement.googleapis.comgcloud services enable --project=PROJECT_ID memorystore.googleapis.com

Replace the following:

  • PROJECT_ID is your project ID.

Create a service connection policy

You must create aservice connection policyfor the project, network, and region where you want to provision theMemorystore for Valkey instance. A service connection policy lets you authorizethegcp-memorystore service class to create a Private Service Connectconnection between producer and consumer VPC networks in the region where thepolicy is defined, and in the subnet that the policy specifies.

To see the permission needed to create a service connection policy, seerequired roles.

This quickstart uses thedefault network anddefault subnet. IP addressesfor your instance are allocated on this default subnet in the region.

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

gcloud

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

Replace the following:

  • POLICY_NAME is your desired policy name.
  • PROJECT_ID is the project ID.
  • REGION is the same region where you want to provision yourMemorystore for Valkey instance.

Validate service connection policy creation

Validate if the policy was created successfully by running thelist command:

gcloud

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

Replace the following:

  • PROJECT_ID is the project ID.
  • REGION is the region where the service connection policy isdefined.

Create an instance

To create an instance, run thecreate command:

gcloud

gcloud memorystore instances createINSTANCE \--project=PROJECT_ID \--location=REGION \--node-type=NODE_TYPE \--shard-count=SHARD_COUNT \--replica-count=REPLICA_COUNT \--endpoints='[{"connections": [{"pscAutoConnection": {"network": "projects/PROJECT_ID/global/networks/NETWORK_ID", "projectId": "PROJECT_ID"}}]}]'

Replace the following:

Note: When running thecreate command you must use the same network and sameregion where the service connection policy is defined.

Describe the instance

To view instance details, run thedescribe command:

Delete the instance

To delete an instance, run thedelete command:

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.