instances

PUT /projects/{project}/zones/{zone}/instances/{instance}

Changed on

Updates an instance only if the necessary resources are available. This method can update only a specific set of instance properties. See Updating a running instance for a list of updatable instance properties.

Request

  • Base URL
    https://compute.googleapis.com/compute/v1
  • URL
    https://compute.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}
  • Auth
    • OAuth 2 and OAuth 2
      Implicit: https://accounts.google.com/o/oauth2/auth
      Scopes: https://www.googleapis.com/auth/cloud-platform
      Authorization code: https://accounts.google.com/o/oauth2/auth
      Token URL: https://accounts.google.com/o/oauth2/token scopes: https://www.googleapis.com/auth/cloud-platform
    • or OAuth 2 and OAuth 2
      Implicit: https://accounts.google.com/o/oauth2/auth
      Scopes: https://www.googleapis.com/auth/compute
      Authorization code: https://accounts.google.com/o/oauth2/auth
      Token URL: https://accounts.google.com/o/oauth2/token scopes: https://www.googleapis.com/auth/compute

Path parameters

projectstring required

Project ID for this request.

zonestring required

The name of the zone for this request.

instancestring required

Name of the instance resource to update.

Query parameters

discardLocalSsdboolean

Whether to discard local SSDs from the instance during restart default value is false.

minimalAction'INVALID' | 'NO_EFFECT' | 'REFRESH' | 'RESTART'

Specifies the action to take when updating an instance even if the updated properties do not require it. If not specified, then Compute Engine acts based on the minimum action that the updated properties require.

mostDisruptiveAllowedAction'INVALID' | 'NO_EFFECT' | 'REFRESH' | 'RESTART'

Specifies the most disruptive action that can be taken on the instance as part of the update. Compute Engine returns an error if the instance properties require a more disruptive action as part of the instance update. Valid options from lowest to highest are NO_EFFECT, REFRESH, and RESTART.

requestIdstring

An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed.

For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments.

The request ID must be a valid UUID with the exception that zero UUID is not supported (00000000-0000-0000-0000-000000000000).

Request body

canIpForwardboolean

Allows this instance to send and receive packets with non-matching destination or source IPs. This is required if you plan to use this instance to forward routes. For more information, seeEnabling IP Forwarding.

cpuPlatformstring

Output only. [Output Only] The CPU platform used by this instance.

creationTimestampstring

Output only. [Output Only] Creation timestamp inRFC3339 text format.

deletionProtectionboolean

Whether the resource should be protected against deletion.

descriptionstring

An optional description of this resource. Provide this property when you create the resource.

fingerprintstring byte

Specifies a fingerprint for this resource, which is essentially a hash of the instance's contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update the instance. You must always provide an up-to-date fingerprint hash in order to update the instance.

To see the latest fingerprint, make get() request to the instance.

hostnamestring

Specifies the hostname of the instance. The specified hostname must be RFC1035 compliant. If hostname is not specified, the default hostname is [INSTANCE_NAME].c.[PROJECT_ID].internal when using the global DNS, and [INSTANCE_NAME].[ZONE].c.[PROJECT_ID].internal when using zonal DNS.

idstring uint64

Output only. [Output Only] The unique identifier for the resource. This identifier is defined by the server.

keyRevocationActionType'KEY_REVOCATION_ACTION_TYPE_UNSPECIFIED' | 'NONE' | 'STOP'

KeyRevocationActionType of the instance. Supported options are "STOP" and "NONE". The default value is "NONE" if it is not specified.

kindstring

Output only. [Output Only] Type of the resource. Always compute#instance for instances.

labelFingerprintstring byte

A fingerprint for this request, which is essentially a hash of the label's contents and used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash in order to update or change labels.

To see the latest fingerprint, make get() request to the instance.

labelsobject

Labels to apply to this instance. These can be later modified by the setLabels method.

lastStartTimestampstring

Output only. [Output Only] Last start timestamp inRFC3339 text format.

lastStopTimestampstring

Output only. [Output Only] Last stop timestamp inRFC3339 text format.

lastSuspendedTimestampstring

Output only. [Output Only] Last suspended timestamp inRFC3339 text format.

localSsdEncryptionMode'EPHEMERAL_KEY_ENCRYPTION' | 'LOCAL_SSD_ENCRYPTION_MODE_UNSPECIFIED' | 'STANDARD_ENCRYPTION'

Specifies which method should be used for encrypting the Local SSDs attached to the VM.

machineTypestring

Full or partial URL of the machine type resource to use for this instance, in the format:zones/zone/machineTypes/machine-type. This is provided by the client when the instance is created. For example, the following is a valid partial url to a predefined machine type:

zones/us-central1-f/machineTypes/n1-standard-1

To create acustom machine type, provide a URL to a machine type in the following format, where CPUS is 1 or an even number up to 32 (2, 4, 6, ... 24, etc), and MEMORY is the total memory for this instance. Memory must be a multiple of 256 MB and must be supplied in MB (e.g. 5 GB of memory is 5120 MB):

zones/zone/machineTypes/custom-CPUS-MEMORY

For example: zones/us-central1-f/machineTypes/custom-4-5120

For a full list of restrictions, read theSpecifications for custom machine types.

minCpuPlatformstring

Specifies aminimum CPU platform for the VM instance. Applicable values are the friendly names of CPU platforms, such as minCpuPlatform: "Intel Haswell" or minCpuPlatform: "Intel Sandy Bridge".

namestring

The name of the resource, provided by the client when initially creating the resource. The resource name must be 1-63 characters long, and comply withRFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [a-z]([-a-z0-9]*[a-z0-9])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.

privateIpv6GoogleAccess'ENABLE_BIDIRECTIONAL_ACCESS_TO_GOOGLE' | 'ENABLE_OUTBOUND_VM_ACCESS_TO_GOOGLE' | 'INHERIT_FROM_SUBNETWORK'

The private IPv6 google access type for the VM. If not specified, use INHERIT_FROM_SUBNETWORK as default.

resourcePoliciesstring[]

Resource policies applied to this instance.

satisfiesPziboolean

Output only. [Output Only] Reserved for future use.

satisfiesPzsboolean

Output only. [Output Only] Reserved for future use.

selfLinkstring

Output only. [Output Only] Server-defined URL for this resource.

sourceMachineImagestring

Source machine image

startRestrictedboolean

Output only. [Output Only] Whether a VM has been restricted for start because Compute Engine has detected suspicious activity.

status'DEPROVISIONING' | 'PENDING' | 'PENDING_STOP' | 'PROVISIONING' | 'REPAIRING' | 'RUNNING' | 'STAGING' | 'STOPPED' | 'STOPPING' | 'SUSPENDED' | 'SUSPENDING' | 'TERMINATED'

Output only. [Output Only] The status of the instance. One of the following values: PROVISIONING, STAGING,RUNNING, STOPPING, SUSPENDING,SUSPENDED, REPAIRING, andTERMINATED. For more information about the status of the instance, see Instance life cycle.

statusMessagestring

Output only. [Output Only] An optional, human-readable explanation of the status.

zonestring

Output only. [Output Only] URL of the zone where the instance resides. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body.

Response

Successful response

clientOperationIdstring

[Output Only] The value of requestId if you provided it in the request. Not present otherwise.

creationTimestampstring

[Deprecated] This field is deprecated.

descriptionstring

[Output Only] A textual description of the operation, which is set when the operation is created.

endTimestring

[Output Only] The time that this operation was completed. This value is inRFC3339 text format.

httpErrorMessagestring

[Output Only] If the operation fails, this field contains the HTTP error message that was returned, such as NOT FOUND.

httpErrorStatusCodeinteger

[Output Only] If the operation fails, this field contains the HTTP error status code that was returned. For example, a 404 means the resource was not found.

idstring uint64

[Output Only] The unique identifier for the operation. This identifier is defined by the server.

insertTimestring

[Output Only] The time that this operation was requested. This value is inRFC3339 text format.

kindstring

Output only. [Output Only] Type of the resource. Always compute#operation for Operation resources.

namestring

[Output Only] Name of the operation.

operationGroupIdstring

Output only. [Output Only] An ID that represents a group of operations, such as when a group of operations results from a bulkInsert API request.

operationTypestring

[Output Only] The type of operation, such as insert, update, or delete, and so on.

progressinteger

[Output Only] An optional progress indicator that ranges from 0 to 100. There is no requirement that this be linear or support any granularity of operations. This should not be used to guess when the operation will be complete. This number should monotonically increase as the operation progresses.

regionstring

[Output Only] The URL of the region where the operation resides. Only applicable when performing regional operations.

selfLinkstring

[Output Only] Server-defined URL for the resource.

startTimestring

[Output Only] The time that this operation was started by the server. This value is inRFC3339 text format.

status'DONE' | 'PENDING' | 'RUNNING'

[Output Only] The status of the operation, which can be one of the following: PENDING, RUNNING, or DONE.

statusMessagestring

[Output Only] An optional textual description of the current status of the operation.

targetIdstring uint64

[Output Only] The unique target ID, which identifies a specific incarnation of the target resource.

targetLinkstring

[Output Only] The URL of the resource that the operation modifies. For operations related to creating a snapshot, this points to the disk that the snapshot was created from.

userstring

[Output Only] User who requested the operation, for example: user@example.com or alice_smith_identifier (global/workforcePools/example-com-us-employees).

zonestring

[Output Only] The URL of the zone where the operation resides. Only applicable when performing per-zone operations.

Changes

    • info

      the security scope https://www.googleapis.com/auth/cloud-platform was added to the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/cloud-platform was added to the endpoint's security scheme Oauth2c

    • info

      the security scope https://www.googleapis.com/auth/compute was removed from the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/compute was removed from the endpoint's security scheme Oauth2c

    • info

      the security scope https://www.googleapis.com/auth/cloud-platform was added to the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/cloud-platform was added to the endpoint's security scheme Oauth2c

    • info

      the security scope https://www.googleapis.com/auth/compute was removed from the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/compute was removed from the endpoint's security scheme Oauth2c