Update instance properties

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

Restrictions

  • Instance update requests through the gcloud CLI orthe Compute Engine API don't supportPATCH semantics. 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 thenetworkInterfaces property 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 theinstances.update method 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.update method to update thoseresources. The v1 version of theinstances.update methoddoesn'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:

  • Thecompute.instances.update permission on the instance that you want toupdate.
  • Eithercompute.disks.use permission for an existing disk orcompute.disks.create on 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 theinstances.update method 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 thedisks.update method
    • To change the network used by the instance, you can use theinstances.updateNetworkInterface method, which doesn't requirestopping the instance.

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 anINFEASIBLE error 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)
  • displayDevice
  • enableNestedVirtualization
  • guestAccelerators
  • machineType
  • minCpuPlatform
  • networkInterfaces
  • networkPerformanceConfig
  • performanceMonitoringUnit
  • reservationAffinity: 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)
  • resourcePolicies
  • scheduling
  • serviceAccounts
  • shieldedInstanceConfig
  • threadsPerCore
  • visibleCoreCount

The following properties only require a refresh (REFRESH) to update:

  • canIpForward
  • deletionProtection
  • description
  • disks: non-boot disk properties, excludingdeviceName
  • labels
  • metadata
  • nodeAffinities
  • tags

Update instance properties

Update your instances using the following steps:

  1. Export the existing instance configuration properties.
  2. Modify the properties of the instance configuration.
  3. Run a test request by specifyingNO_EFFECT as the most disruptive action.The response indicates invalid fields in the instance configuration andindicates the action required to apply the changes.
  4. 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 instancefingerprint property in your request must match thefingerprint of 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 specifyRESTART as 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

  1. Use theinstances 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.
  2. 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 themachineType property:

    ...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.
    Tip: To avoid getting an error such as"ERROR: (gcloud.compute.instances.update-from-file) Cannot parse YAML: [Expected type for field value, found True (type)]", add quotes (' ') around any label values ofyes orno in the exported instance configuration file. This indicates the values are strings, not Boolean values.
  3. Use theinstances update-from-filecommand to run atest update of the target instance. Specify the--most-disruptive-allowed-action=NO_EFFECT flag. The response identifiesmisconfigured properties and indicates whether aRESTART orREFRESHaction 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.
  4. Use theinstances 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=REFRESH flag. 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. SpecifyRESTART to allow for a full restart of theinstance. SpecifyREFRESH to 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

  1. Use theinstances.get methodin 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.

  2. 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 themachineType property. 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.
  3. Use theinstances.update methodin the Compute Engine API and specify themostDisruptiveAllowedAction=NO_EFFECT query parameter to run a testupdate of the target instance. The response identifies misconfiguredproperties and indicates if aRESTART orREFRESH action 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.
  4. Use theinstances.update methodin the Compute Engine API to update the target instance.If you are updating a property that requires an instance restart,include themostDisruptiveAllowedAction=RESTART query parameter toindicate that the instance can be restarted during the update. If theproperties don't require a restart, specify themostDisruptiveAllowedAction=REFRESH query 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. SpecifyRESTART to allow for a full restart of the instance. SpecifyREFRESH to 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

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.