gcloud alpha compute instances set-scopes Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud alpha compute instances set-scopes - set scopes and service account for a Compute Engine VM instance
- SYNOPSIS
gcloud alpha compute instances set-scopesINSTANCE_NAME[--zone=ZONE][--scopes=[SCOPE,…] |--no-scopes][--service-account=SERVICE_ACCOUNT|--no-service-account][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
(ALPHA)gcloud alpha compute instances set-scopesletsyou configure service account and scopes for a Compute Engine VM instance.Note: This command might be deprecated in a future release. Use
gcloudcompute instances set-service-accountinstead.- EXAMPLES
- To set a service account with the
scope, run:cloud-platformgcloudalphacomputeinstancesset-scopesexample-instance--scopes=cloud-platform--zone=us-central1-b--service-account=example-account - POSITIONAL ARGUMENTS
INSTANCE_NAME- Name of the instance to operate on. For details on valid instance names, referto the criteria documented under the field 'name' at:https://cloud.google.com/compute/docs/reference/rest/v1/instances
- FLAGS
--zone=ZONE- Zone of the instance to operate on. If not specified, you might be prompted toselect a zone (interactive mode only).
gcloudattempts to identify theappropriate zone by searching for resources in your currently active project. Ifthe zone cannot be determined,gcloudprompts you for a selection withall available Google Cloud Platform zones.To avoid prompting when this flag is omitted, the user can set the
property:compute/zonegcloudconfigsetcompute/zoneZONEA list of zones can be fetched by running:
gcloudcomputezoneslistTo unset the property, run:
gcloudconfigunsetcompute/zoneAlternatively, the zone can be stored in the environment variable
.CLOUDSDK_COMPUTE_ZONE - At most one of these can be specified:
--scopes=[SCOPE,…]- If not provided, the instance will keep the scopes it currently has.
SCOPE can be either the full URI of the scope or an alias.
Defaultscopes are assigned to all instances. Available aliases are:
DEPRECATION WARNING:https://www.googleapis.com/auth/sqlserviceaccount scope andAlias URI bigquery https://www.googleapis.com/auth/bigquery cloud-platform https://www.googleapis.com/auth/cloud-platform cloud-source-repos https://www.googleapis.com/auth/source.full_control cloud-source-repos-ro https://www.googleapis.com/auth/source.read_only compute-ro https://www.googleapis.com/auth/compute.readonly compute-rw https://www.googleapis.com/auth/compute datastore https://www.googleapis.com/auth/datastore default https://www.googleapis.com/auth/devstorage.read_only https://www.googleapis.com/auth/logging.write https://www.googleapis.com/auth/monitoring.write https://www.googleapis.com/auth/pubsub https://www.googleapis.com/auth/service.management.readonly https://www.googleapis.com/auth/servicecontrol https://www.googleapis.com/auth/trace.append gke-default https://www.googleapis.com/auth/devstorage.read_only https://www.googleapis.com/auth/logging.write https://www.googleapis.com/auth/monitoring https://www.googleapis.com/auth/service.management.readonly https://www.googleapis.com/auth/servicecontrol https://www.googleapis.com/auth/trace.append logging-write https://www.googleapis.com/auth/logging.write monitoring https://www.googleapis.com/auth/monitoring monitoring-read https://www.googleapis.com/auth/monitoring.read monitoring-write https://www.googleapis.com/auth/monitoring.write pubsub https://www.googleapis.com/auth/pubsub service-control https://www.googleapis.com/auth/servicecontrol service-management https://www.googleapis.com/auth/service.management.readonly sql (deprecated) https://www.googleapis.com/auth/sqlservice sql-admin https://www.googleapis.com/auth/sqlservice.admin storage-full https://www.googleapis.com/auth/devstorage.full_control storage-ro https://www.googleapis.com/auth/devstorage.read_only storage-rw https://www.googleapis.com/auth/devstorage.read_write taskqueue https://www.googleapis.com/auth/taskqueue trace https://www.googleapis.com/auth/trace.append userinfo-email https://www.googleapis.com/auth/userinfo.email sqlalias do not provide SQL instance managementcapabilities and have been deprecated. Please, usehttps://www.googleapis.com/auth/sqlservice.adminorsql-adminto manage your Google SQL Service instances. --no-scopes- Remove all scopes from the instance
- At most one of these can be specified:
--service-account=SERVICE_ACCOUNT- A service account is an identity attached to the instance. Its access tokens canbe accessed through the instance metadata server and are used to authenticateapplications on the instance. The account can be set using an email addresscorresponding to the required service account. You can explicitly specify theCompute Engine default service account using the 'default' alias.
If not provided, the instance will use the service account it currently has.
--no-service-account- Remove service account from the instance
- GCLOUD WIDE FLAGS
- These flags are available to all commands:
--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 helpfor details. - NOTES
- This command is currently in alpha and might change without notice. If thiscommand fails with API permission errors despite specifying the correct project,you might be trying to access an API with an invitation-only early accessallowlist. This variant is also available:
gcloudbetacomputeinstancesset-scopes
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 2025-05-07 UTC.