Stay organized with collections Save and categorize content based on your preferences.
Linux Windows
The Google Cloud CLI lets you manage your Compute Engine resources, using the gcloud compute
command group. gcloud compute
is an alternative to using the Compute Engine API.
The gcloud CLI is part of the Google Cloud CLI and is a unified command-line tool that includes features like statement autocompletion, in-place updating, command-line help, human-readable and machine-parsable output formats, and integration with Google Cloud CLI.
Note: Looking for reference pages forgcloud compute
commands? Try the command-line --help
function. For example, to get help about instance creation, use gcloud compute instances create --help
. You can see all command-line documentation at Google Cloud CLI reference.
If you have never used Compute Engine, get started with either the Linux quickstart or the Windows quickstart.
Before you begingcloud compute
in a command prompt, install, update, and initialize the Google Cloud CLI.gcloud compute
in Cloud Shell. Cloud Shell is automatically installed, updated, and initialized with the latest Google Cloud CLI.When you create a virtual machine instance, Compute Engine configures a VM using default properties from the metadata server. You can check your VM's default properties by running the following command:
gcloud compute project-info describe --project PROJECT_ID
Replace PROJECT_ID
with your project ID.
If you set a default project when you setup and initialize the Google Cloud CLI, all gcloud compute
commands use that project ID by default.
You can override the default project ID by using either of the following methods:
gcloud compute
command with the --project
flagSet the CLOUDSDK_CORE_PROJECT
environment variable
Use the export
command to set the project environment variable.
export CLOUDSDK_CORE_PROJECT=PROJECT_ID
Replace PROJECT_ID
with the project ID of the project that you want to use as default.
Unsetting project environment variables
If you need to unset your project environment variables, use the following unset
commands:
unset CLOUDSDK_CORE_PROJECTWindows
Use the set
command to set the project environment variable.
set CLOUDSDK_CORE_PROJECT=PROJECT_ID
Replace PROJECT_ID
with the project ID of the project that you want to use as default.
Unsetting project environment variables
If you need to unset your project environment variables, use the following command:
set CLOUDSDK_CORE_PROJECT=
If you do not set a default project or environment variable, you must include a --project
flag in each gcloud compute
command that you run.
Some gcloud compute
commands require --region
or --zone
flags. Instead of specifying these flags each time you run commands, you can set a default region and zone for your project. If you don't set a default region or zone and you run a region- or zone-dependent command, the Google Cloud CLI might prompt you to provide a --region
or --zone
flag, or return an error.
You can set the default region and zone in three ways:
gcloud init
.You can override the default region and zone in the metadata server, in your local client, or in environment variables, by providing --region
and --zone
flags when you run commands.
To view your default region and zone, run the following commands:
gcloud config get-value compute/region
gcloud config get-value compute/zone
If the output is (unset)
, no default region or zone is set.
You can view a list of regions and zones by running the following commands:
gcloud compute regions list
gcloud compute zones listSet default region and zone in the metadata server
The default region and zone in the metadata server apply to all configurations in your project. To set the default region and zone in the metadata server, do the following:
Set the default region and zone:
gcloud compute project-info add-metadata \ --metadata google-compute-default-region=REGION,google-compute-default-zone=ZONE
For example:
gcloud compute project-info add-metadata \ --metadata google-compute-default-region=europe-west1,google-compute-default-zone=europe-west1-b
Initialize the change in your local client:
gcloud init
You can override the default region and zone set in the metadata server by setting the default region and zone in your local client, setting the default region and zone in environment variables, or by including the --zone
or --region
flag in your commands.
To unset the default region and zone in the metadata server, do the following:
Unset metadata:
gcloud compute project-info remove-metadata \ --keys=google-compute-default-region,google-compute-default-zone
Initialize the change in your local client:
gcloud init
The default region and zone set in your local client override the default region and zone set in the metadata server.
To set the default region and zone in your local client, run the following commands:
gcloud config set compute/region REGION
gcloud config set compute/zone ZONEUnset default region and zone in your local client
To unset the default region or zone in your local client, run the following commands:
gcloud config unset compute/zone
gcloud config unset compute/region
You can override the default region and zone set in your local client by setting the default region and zone in environment variables, or by including the --zone
or --region
flag in your commands.
The default region and zone set in environment variables override the default region and zone set in your local client and in the metadata server.
Linux and macOSUse the export
command to set the region and zone variables.
export CLOUDSDK_COMPUTE_REGION=REGION
export CLOUDSDK_COMPUTE_ZONE=ZONE
To make these environment variables permanent, include these commands in your ~/.bashrc
file and restart your terminal.
Use the set
command to set the region and zone variables.
set CLOUDSDK_COMPUTE_REGION=REGION
set CLOUDSDK_COMPUTE_ZONE=ZONE
You can override environment variables by including the --zone
or --region
flag in your commands.
Use the following commands to unset the default region and zone in environment variables.
Linux and macOSTo unset your region and zone environment variables, use the following unset
commands:
unset CLOUDSDK_COMPUTE_REGION
unset CLOUDSDK_COMPUTE_ZONEWindows
To unset your region and zone environment variables, use the following commands:
set CLOUDSDK_COMPUTE_REGION=
set CLOUDSDK_COMPUTE_ZONE=Override default zone with flags
Use the --zone
flag to override the default zone set in the metadata server, your local client, and environment variables.
For example:
gcloud compute instances create example-instance \ --zone=ZONEConfigurations
gcloud topic configurations
are an advanced feature that you can use to influence the behavior of the gcloud CLI. For most users, using default configurations is sufficient.
Configurations might be useful for users who:
To switch between configurations, run the following command:
gcloud config configurations activate CONFIGURATION_NAME
For more information about managing configurations, see gcloud config configurations
.
gcloud compute
usage tips.gcloud compute
commands.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 2025-08-13 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-13 UTC."],[[["The Google Cloud CLI's `gcloud compute` command group lets you manage Compute Engine resources, and is an alternative to using the Compute Engine API."],["You can set a default project for `gcloud compute` commands, either during Google Cloud CLI initialization or by using the `--project` flag or `CLOUDSDK_CORE_PROJECT` environment variable."],["Default region and zone can be set in the metadata server, local client, or environment variables, with environment variables having the highest precedence, and can be viewed using the `gcloud config get-value` commands."],["You can override default settings by using flags like `--region` and `--zone` when running `gcloud compute` commands."],["`gcloud topic configurations` is an advanced feature that lets you influence the behavior of the gcloud CLI, and is useful for those with multiple projects or accounts."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4