Select the tab for how you plan to use the samples on this page:
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
After installing the Google Cloud CLI, initialize it by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
To use the Terraform samples on this page in a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
To initialize the gcloud CLI, run the following command:
gcloudinit
If you're using a local shell, then create local authentication credentials for your user account:
gcloudauthapplication-defaultlogin
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
For more information, see Set up authentication for a local development environment.
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
After installing the Google Cloud CLI, initialize it by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
If you need to align replication across multiple disks, create a consistency group in the same region as the primary disks. If you need to align disk clones, create a consistency group in the same region as the secondary disks.
Create a consistency group using the Google Cloud console, the Google Cloud CLI, REST, or Terraform.
Create a consistency group by doing the following:
In the Google Cloud console, go to the Asynchronous replication page.
Click the Consistency groups tab.
Click Create consistency group.
In the Name field, enter a name for the consistency group.
In the Region field, select the region where your disks are located. If you want to add primary disks to consistency group, select the primary region. If you want to add secondary disks to the consistency group, select the secondary region.
Click Create.
Create a consistency group using the gcloud compute resource-policies create disk-consistency-group
command:
gcloud compute resource-policies create disk-consistency-group CONSISTENCY_GROUP_NAME \ --region=REGION
Replace the following:
CONSISTENCY_GROUP_NAME
: the name for the consistency group.REGION
: the region for the consistency group. If you want to add primary disks to consistency group, use the primary region. If you want to add secondary disks to the consistency group, use the secondary region.Create a consistency group using the resourcePolicies.insert
method:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT/regions/REGION/resourcePolicies { "name": "CONSISTENCY_GROUP_NAME", "diskConsistencyGroupPolicy": { } }
Replace the following:
PROJECT
: the project that contains the consistency group.REGION
: the region for the consistency group. If you want to add primary disks to consistency group, use the same region as the primary disks. If you want to add secondary disks to the consistency group, use the same region as the secondary disks.CONSISTENCY_GROUP_NAME
: the name for the consistency group. To create a consistency group, use the compute_resource_policy
resource.
To learn how to apply or remove a Terraform configuration, see Basic Terraform commands.
View disks in a consistency group using the Google Cloud console, the Google Cloud CLI, or REST.
View the disks included in a consistency group by doing the following:
In the Google Cloud console, go to the Asynchronous replication page.
Click the Consistency groups tab.
Click the name of the consistency group that you want to view the disks for. The Manage consistency group page opens.
View the Consistency group members section to see all disks included in the consistency group.
View the disks included in a consistency group using the gcloud compute disks list
command:
gcloud compute disks list \ --LOCATION_FLAG=LOCATION \ --filter=resourcePolicies=CONSISTENCY_GROUP_NAME
Replace the following:
LOCATION_FLAG
: the location flag for the disks in the consistency group. If the disks in the consistency group are regional, use --region
. If the disks in the consistency group are zonal, use --zone
.LOCATION
: the region or zone of the disks in the consistency group. For regional disks, use the region. For zonal disks, use the zone.CONSISTENCY_GROUP_NAME
: the name of the consistency group.View the disks in a consistency group by using a query filter with one of the following methods:
View zonal disks in a consistency group using the disks.get
method:
GET https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/disks?filter=resourcePolicies%3DCONSISTENCY_GROUP_NAME
View regional disks in a consistency group using the regionDisks.get
method:
GET https://compute.googleapis.com/compute/v1/projects/PROJECT/regions/REGION/disks?filter=resourcePolicies%3DCONSISTENCY_GROUP_NAME
Replace the following:
PROJECT
: the project that contains the consistency groupZONE
: the zone of the disks in the consistency groupREGION
: the region of the disks in the consistency groupCONSISTENCY_GROUP_NAME
: the name of the consistency groupIf you want to add primary disks to a consistency group, you must add disks to the consistency group before you start replication. You can add secondary disks to a consistency group at any time. All disks in a consistency group must be in the same zone, for zonal disks, or in the same pair of zones, for regional disks.
Add a disk to a consistency group using the Google Cloud console, the Google Cloud CLI, REST, or Terraform.
Add disks to a consistency group by doing the following:
In the Google Cloud console, go to the Asynchronous replication page.
Click the Consistency groups tab.
Click the name of the consistency group that you want to add disks to. The Manage consistency group page opens.
Click Assign disks. The Assign disks page opens.
Select the disks that you want to add to the consistency group.
Click Assign disks. When prompted, click Add.
Add a disk to a consistency group using the gcloud compute disks add-resource-policies
command:
gcloud compute disks add-resource-policies DISK_NAME \ --LOCATION_FLAG=LOCATION \ --resource-policies=CONSISTENCY_GROUP
Replace the following:
DISK_NAME
: the name of the disk to add to the consistency group.LOCATION_FLAG
: the location flag for the disk. For a regional disk, use --region
. For a zonal disk, use --zone
.LOCATION
: the region or zone of the disk. For regional disks, use the region. For zonal disks, use the zone.CONSISTENCY_GROUP
: the URL of the consistency group. For example, projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME
.Add disks to a consistency group using one of the following methods:
Add zonal disks to a consistency group using the disks.addResourcePolicies
method:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/LOCATION/disks/DISK_NAME/addResourcePolicies { "resourcePolicies": "CONSISTENCY_GROUP" }
Add regional disks to a consistency group using the regionDisks.addResourcePolicies
method:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT/regions/LOCATION/disks/DISK_NAME/addResourcePolicies { "resourcePolicies": "CONSISTENCY_GROUP" }
Replace the following:
PROJECT
: the project that contains the disk.LOCATION
: the zone or region of the disk. For zonal disks, use the zone. For regional disks, use the region.DISK_NAME
: the name of the disk to add to the consistency group.CONSISTENCY_GROUP
: the URL of the consistency group. For example, projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME
.To add the disk to the consistency group, use the compute_disk_resource_policy_attachment
resource.
In case of Regional disk specify region in place of zone.
To learn how to apply or remove a Terraform configuration, see Basic Terraform commands.
Before you can remove a disk from a consistency group, you must stop replication for the disk.
Remove a disk from a consistency group using the Google Cloud console, the Google Cloud CLI, or REST.
Remove primary disks from a consistency group by doing the following:
In the Google Cloud console, go to the Asynchronous replication page.
Click the Consistency groups tab.
Click the name of the consistency group that you want to add disks to. The Manage consistency group page opens.
Select the disks that you want to remove from the consistency group.
Click Remove disks. When prompted, click Remove.
Remove a disk from a consistency group using the gcloud compute disks remove-resource-policies
command:
gcloud compute disks remove-resource-policies DISK_NAME \ --LOCATION_FLAG=LOCATION \ --resource-policies=CONSISTENCY_GROUP
Replace the following:
DISK_NAME
: the name of the disk to remove from the consistency group.LOCATION_FLAG
: the location flag for the disk. For a regional disk, use --region
. For a zonal disk, use --zone
.LOCATION
: the region or zone of the disk. For regional disks, use the region. For zonal disks, use the zone.CONSISTENCY_GROUP
: the URL of the consistency group. For example, projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME
.Remove a disk from a consistency group using the disks.removeResourcePolicies
method for zonal disks, or the regionDisks.removeResourcePolicies
method for regional disks.
Remove a zonal disk from a consistency group:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/LOCATION/disks/DISK_NAME/removeResourcePolicies { "resourcePolicies": "CONSISTENCY_GROUP" }
Remove a regional disk from a consistency group:
POST https://compute.googleapis.com/compute/v1/projects/PROJECT/regions/LOCATION/disks/DISK_NAME/removeResourcePolicies { "resourcePolicies": "CONSISTENCY_GROUP" }
Replace the following:
PROJECT
: the project that contains the disk.LOCATION
: the zone or region of the disk. For zonal disks, use the zone. For regional disks, use the region.DISK_NAME
: the name of the disk to remove from the consistency group.CONSISTENCY_GROUP
: the URL of the consistency group. For example, projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME
.Delete a consistency group using the Google Cloud console, the Google Cloud CLI, or REST.
Delete a consistency by doing the following:
In the Google Cloud console, go to the Asynchronous replication page.
Click the Consistency groups tab.
Select the consistency group that you want to delete.
Click Delete. The Delete consistency group window opens.
Click Delete.
Delete the resource policy using the gcloud compute resource-policies delete
command:
gcloud compute resource-policies delete CONSISTENCY_GROUP \ --region=REGION
Replace the following:
CONSISTENCY_GROUP
: the name of the consistency groupREGION
: the region of the consistency groupDelete a consistency using the resourcePolicies.delete
method:
DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME
Replace the following:
PROJECT
: the project that contains the consistency groupREGION
: the region of the consistency groupCONSISTENCY_GROUP
: the name of the consistency groupExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-04-22 UTC.