Update instance properties Stay organized with collections Save and categorize content based on your preferences.
You can use a single request from theGoogle Cloud CLI or theCompute Engine APIto update multiple instance properties and optionallyrestart the instance if necessary. The update method handles the logic forvalidating the updated instance properties and ensuring that the necessaryresources are available to complete the update successfully. If the requestincludes invalid properties or if the requested resources are not available,the request returns an error and makes no changes to your instance. Thisprotects the instance from partial updates and protects the instance frombeing stopped and unable to access resources to start up again.
To update the network interfaces (networkInterfaces) of an instance,see insteadUpdate the network interfaces for an instance.
To add or remove Dynamic Network Interfaces from an instance, use the followingprocedures instead of updating the instance properties:
Before you begin
- If you haven't already, set upauthentication. Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI 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.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.- Set a default region and zone.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI 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.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.For more information, seeAuthenticate for using REST in the Google Cloud authentication documentation.
Restrictions
- Instance update requests through the gcloud CLI orthe Compute Engine API don't support
PATCHsemantics. Theinstance resource in the update request must include all of the propertiesof the instance. Properties that are missing from the instance configurationin your update request are considered to be deleted from the instance. - You can update only aspecific list of properties.
- Changing instances to and from sole tenancy is not supported.
- You can change an instance from one reservation to another, but you cannotattach or detach an instance to a reservation using the update process.
- If the instance has Local SSD disks attached, you can't update properties thatrequire the instance to restart while the instance is running. You can deleteand then recreate the instance, orstop the instance, update theproperties,and then restart it.
- You can update the
networkInterfacesproperty of an instance, but you can'tadd virtual NICs (vNICs) to or remove vNICs from an instance. - If an instance uses resources that are available only in the betaCompute Engine API, you must use the correct version of the
instances.updatemethod to update those properties. For example, if youcreate an instance using the beta Compute Engine API and configurethe instance with a resource that only the beta API recognizes, you mustalso use the beta version of theinstances.updatemethod to update thoseresources. The v1 version of theinstances.updatemethoddoesn't recognize the beta resources that your instance uses, so it deletesthose beta resources from the instance configuration during the updateprocess. This behavior also applies to resources in the alpha API.
Permissions
You must have thecompute.instances.update permission to update instances.This permission is included in severalexisting Identity and Access Management (IAM) roles.You must also have permission to use the resources that you want to modify onthe instance. For example, to add a disk to an instance you must have thefollowing permissions:
- The
compute.instances.updatepermission on the instance that you want toupdate. - Either
compute.disks.usepermission for an existing disk orcompute.disks.createon a project where you want to create a new disk.
Best practices
To ensure that the instance update interface works most effectively for you,use the following best practices:
- If possible, consistently use the same version of theCompute Engine API to create, set, and update instances. Thisensures that you can update and modify any instance resources if they areavailable only in one version of the API.
- Although you can use the
instances.updatemethod to update instances in amanaged instance group (MIG),for most situations it is better to change theinstance template of the group androll that update out to the MIGinstead. - If updating a resource that is used by the instance, use the command to updatethat resource instance of updating the instance properties, for example:
- You can modify disks with the
disks.updatemethod - To change the network used by the instance, you can use the
instances.updateNetworkInterfacemethod, which doesn't requirestopping the instance.
- You can modify disks with the
Properties that you can update
You can change only a specific set of instance properties through the updatemethod. Updates to some properties require the instance to restart.To prevent accidental restarts on your instances, your request must definewhat action is allowed to be taken on your instances. Your request canspecify one of the following actions:
NO_EFFECT: the update request checks to see if the request is valid andif the resources are available, but it doesn't execute the update. Use thisaction to test commands without initiating any actual updates.REFRESH: the update request runs only if the modified instanceproperties don't require the instance to restart. The request returns anINFEASIBLEerror if the request is valid but a restart is required.RESTART: if the update requires the instance to restart, then the systemwill restart your instance.
The following properties require a restart (RESTART) to update:
disks: boot disks, including all disks (disks.deviceName)displayDeviceenableNestedVirtualizationguestAcceleratorsmachineTypeminCpuPlatformnetworkInterfacesnetworkPerformanceConfigperformanceMonitoringUnitreservationAffinity: You can only update how the instance consumesreservations (reservationAffinity.consumeReservationType) as follows:- From consuming any matching reservation (
ANY_RESERVATION) to not consumingreservations (NO_RESERVATION) - From not consuming reservations (
NO_RESERVATION) to consuming any matchingreservations (ANY_RESERVATION)
- From consuming any matching reservation (
resourcePoliciesschedulingserviceAccountsshieldedInstanceConfigthreadsPerCorevisibleCoreCount
The following properties only require a refresh (REFRESH) to update:
canIpForwarddeletionProtectiondescriptiondisks: non-boot disk properties, excludingdeviceNamelabelsmetadatanodeAffinitiestags
Update instance properties
Update your instances using the following steps:
- Export the existing instance configuration properties.
- Modify the properties of the instance configuration.
- Run a test request by specifying
NO_EFFECTas the most disruptive action.The response indicates invalid fields in the instance configuration andindicates the action required to apply the changes. - If the configuration is acceptable, request an instance update and specifythe most disruptive action that is acceptable for your instance update.
The system starts the update process only if your request meets the followingrequirements:
- The instance
fingerprintproperty in your request must match thefingerprintof the instance that you are updating. This preventssimultaneous update requests on the same instance from overwritingeach other. - The properties in your update request must be valid.
- The resources that you requested must be available.
- If the properties in your request require the instance to restart, yourrequest must specify
RESTARTas an allowed action.
If the requirements are met, the system starts the instance update process.Otherwise, the system makes no changes to your existing instance or itsconfiguration.
You can initiate updates using either the gcloud CLI or theCompute Engine API.
gcloud
Use the
instances exportcommand to export theexisting instance properties:gcloud compute instances exportINSTANCE_NAME \ --projectPROJECT_ID \ --zoneZONE \ --destination=FILE_PATH
Replace the following:
INSTANCE_NAME: the name for the instancethat you want to export.PROJECT_ID: the project ID for this request.ZONE: thezone forthis instance.FILE_PATH: the output path where you wantto save the instance configuration file on your local workstation.
Use a text editor to modify one or more properties in the exportedinstance configuration file. To learn which properties you can update, seethelist of updatable properties in this document.For example, to change the machine type of the instance, change the
machineTypeproperty:...machineType: https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/machineTypes/MACHINE_TYPE...
Replace the following:
PROJECT_ID: the project ID for this request.ZONE: thezone forthis instance.MACHINE_TYPE: themachine type of theinstance, for example,n1-standard-2.
"ERROR: (gcloud.compute.instances.update-from-file) Cannot parse YAML: [Expected type, add quotes (for field value, found True (type )]" ' ') around any label values ofyesornoin the exported instance configuration file. This indicates the values are strings, not Boolean values.Use the
instances update-from-filecommand to run atest update of the target instance. Specify the--most-disruptive-allowed-action=NO_EFFECTflag. The response identifiesmisconfigured properties and indicates whether aRESTARTorREFRESHaction is required to apply the update.gcloud compute instances update-from-fileINSTANCE_NAME \ --projectPROJECT_ID \ --zoneZONE \ --source=FILE_PATH \ --most-disruptive-allowed-action NO_EFFECT
Replace the following:
INSTANCE_NAME: the name for the instanceyou want to export.PROJECT_ID: the project ID for this request.ZONE: thezone forthis instance.FILE_PATH: the path to the modified instanceconfiguration file on your local workstation.
Use the
instances update-from-filecommand to updatethe target instance. If you are updating a property that requires theinstance to restart, include the--most-disruptive-allowed-action=RESTARTflag. If the properties don't require a restart, specify the--most-disruptive-allowed-action=REFRESHflag. To learn which propertiesrequire a restart, see theupdatable properties list in this document.gcloud compute instances update-from-fileINSTANCE_NAME \ --projectPROJECT_ID \ --zoneZONE \ --source=FILE_PATH \ --most-disruptive-allowed-actionALLOWED_ACTION
Replace the following:
INSTANCE_NAME: the name for the instanceyou want to export.PROJECT_ID: the project ID for this request.ZONE: thezone forthis instance.FILE_PATH: the path to the modified instanceconfiguration file on your local workstation.ALLOWED_ACTION: defines how disruptive theupdate can be. SpecifyRESTARTto allow for a full restart of theinstance. SpecifyREFRESHto update the instance only if themodified properties don't require the instance to restart.
If the update request is valid and the required resources are available,the instance update process begins. You can monitor the status of thisoperation byviewing the audit logs.If the update requires a restart and your command allows for aRESTART, the instance restarts to apply the changes.
REST
Use the
instances.getmethodin the Compute Engine API to export the existing instanceproperties:GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME
Replace the following:
PROJECT_ID: the project ID for this request.ZONE: thezone for thisinstance.INSTANCE_NAME: the name for the instance youwant to export.
This request returns aninstance resource definition.
In the response, modify the instance resource properties. To learn whichproperties are updatable, see theupdatable properties list in this document. Forexample, to change the machine type of the instance, change the
machineTypeproperty. You can change multiple properties.{ ... "machineType": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/machineTypes/MACHINE_TYPE", ...}Replace the following:
PROJECT_ID: the project ID for this request.ZONE: thezone forthis instance.MACHINE_TYPE: themachine typeof the instance, for example,n1-standard-2.
Use the
instances.updatemethodin the Compute Engine API and specify themostDisruptiveAllowedAction=NO_EFFECTquery parameter to run a testupdate of the target instance. The response identifies misconfiguredproperties and indicates if aRESTARTorREFRESHaction is requiredto apply the update.PUT https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME?mostDisruptiveAllowedAction=NO_EFFECT{ ... "machineType": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/machineTypes/n1-standard-2", ...}Replace the following:
PROJECT_ID: the project ID for this request.ZONE: thezone forthis instance.INSTANCE_NAME: the name for the instance youwant to export.
Use the
instances.updatemethodin the Compute Engine API to update the target instance.If you are updating a property that requires an instance restart,include themostDisruptiveAllowedAction=RESTARTquery parameter toindicate that the instance can be restarted during the update. If theproperties don't require a restart, specify themostDisruptiveAllowedAction=REFRESHquery parameter. To learn whichproperties require a restart, see theupdatable properties list in this document.Include the full body for the instance resource that you modified. In thefollowing example, the body changes the machine type ton1-standard-2:PUT https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME?mostDisruptiveAllowedAction=ALLOWED_ACTION{ ... "machineType": "https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/machineTypes/n1-standard-2", ...}Replace the following:
PROJECT_ID: the project ID for this request.ZONE: thezone forthis instance.INSTANCE_NAME: the name for the instance youwant to export.ALLOWED_ACTION: defines how disruptive theupdate can be. SpecifyRESTARTto allow for a full restart of the instance. SpecifyREFRESHto update the instance only if the modified properties don'trequire the instance to restart.
If the update request is valid and the required resources are available,the instance update process begins. You can monitor the status of thisoperation byviewing the audit logs.If the update requires a restart and your command allows for aRESTART, the instance restarts to apply the changes.
What's next
- Check the instance'sstate.
- Learn how toreserve resources in aspecific zone.
- Learn how toUpdate the network interfaces for an instance.
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-12-15 UTC.