gcloud compute disks update-kms-key DISK_NAME [--kms-key=KMS_KEY : --kms-keyring=KMS_KEYRING --kms-location=KMS_LOCATION --kms-project=KMS_PROJECT] [--region=REGION | --zone=ZONE] [GCLOUD_WIDE_FLAG …]
gcloud compute disks update-kms-key updates the KMS key of a
Compute Engine Persistent or Hyperdisk Disk by rotating it to the primary
version of the key or to the primary version of a new KMS key.
example-disk-1 to the primary
version, run:
gcloud compute disks update-kms-key example-disk-1 --zone=us-central1-a
To change the KMS key of a disk named example-disk-2 to a new KMS
key named example-key in a key ring named example-key-ring in the global scope,
run:
gcloud compute disks update-kms-key example-disk-2 --zone=us-central1-a --kms-key=example-key --kms-keyring=example-key-ring --kms-location=globalDISK_NAME--kms-key=KMS_KEY
To set the kms-key attribute:
--kms-key on the command line.
--kms-keyring=KMS_KEYRINGkms-keyring attribute:
--kms-key on the command line with a fully
specified name;
--kms-keyring on the command line.
--kms-location=KMS_LOCATIONkms-location attribute:
--kms-key on the command line with a fully
specified name;
--kms-location on the command line;
--region on the command line.
--kms-project=KMS_PROJECTkms-project attribute:
--kms-key on the command line with a fully
specified name;
--kms-project on the command line;
core/project.
--region=REGION
To avoid prompting when this flag is omitted, you can set the
property:
compute/region
gcloud config set compute/region REGIONA list of regions can be fetched by running:
gcloud compute regions listTo unset the property, run:
gcloud config unset compute/regionCLOUDSDK_COMPUTE_REGION.
--zone=ZONEcompute/zone property isn't set, you might
be prompted to select a zone (interactive mode only).
To avoid prompting when this flag is omitted, you can set the
property:
compute/zone
gcloud config set compute/zone ZONEA list of zones can be fetched by running:
gcloud compute zones listTo unset the property, run:
gcloud config unset compute/zoneCLOUDSDK_COMPUTE_ZONE.
--access-token-file,
--account, --billing-project,
--configuration,
--flags-file,
--flatten, --format, --help, --impersonate-service-account,
--log-http,
--project, --quiet, --trace-token, --user-output-enabled,
--verbosity.
Run $ gcloud help for details.
gcloud alpha compute disks update-kms-keygcloud beta compute disks update-kms-keygcloud preview compute disks update-kms-key
Except 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 2026-05-27 UTC.