gcloud beta compute instances set-machine-type Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud beta compute instances set-machine-type - set machine type for Compute Engine virtual machines
- SYNOPSIS
gcloud beta compute instances set-machine-typeINSTANCE_NAME[--machine-type=MACHINE_TYPE][--zone=ZONE][--custom-cpu=CUSTOM_CPU--custom-memory=CUSTOM_MEMORY:--custom-extensions--custom-vm-type=CUSTOM_VM_TYPE][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
(BETA)lets you change the machine type of avirtual machine in thegcloud beta compute instancesset-machine-typeTERMINATEDstate (that is, a virtual machineinstance that has been stopped).For example, if
is aexample-instancevirtual machine currently in theg1-smallTERMINATEDstate, running:gcloudbetacomputeinstancesset-machine-typeexample-instance--zoneus-central1-b--machine-typen1-standard-4will change the machine type to
, so that when you next startn1-standard-4, it will be provisioned asanexample-instanceinstead of an1-standard-4.g1-smallSeehttps://cloud.google.com/compute/docs/machine-typesfor more information on machine types.
- EXAMPLES
- To change the machine type of a VM to
n1-standard-4, run:gcloudbetacomputeinstancesset-machine-typeexample-instance--zone=us-central1-b--machine-type=n1-standard-4 - 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
--machine-type=MACHINE_TYPE- Specifies the machine type used for the instances. To get a list of availablemachine types, run 'gcloud compute machine-types list'. Either this flag,--custom-cpu, or --custom-memory must be specified.
--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 - Custom machine type extensions.
--custom-cpu=CUSTOM_CPU- A whole number value specifying the number of cores that are needed in thecustom machine type.
For some machine types, shared-core values can also be used. For example, for E2machine types, you can specify
micro,small, ormedium.This flag argument must be specified if any of the other arguments in this groupare specified.
--custom-memory=CUSTOM_MEMORY- A whole number value indicating how much memory is desired in the custom machinetype. A size unit should be provided (eg. 3072MB or 9GB) - if no units arespecified, GB is assumed.
This flag argument must be specified if any of the other arguments in this groupare specified.
--custom-extensions- Use the extended custom machine type.
--custom-vm-type=CUSTOM_VM_TYPE- Specifies a custom machine type. The default is
n1. For moreinformation about custom machine types, see:https://cloud.google.com/compute/docs/general-purpose-machines#custom_machine_types
- 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 beta and might change without notice. Thesevariants are also available:
gcloudcomputeinstancesset-machine-typegcloudalphacomputeinstancesset-machine-type
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.