v1

latestOpenAPI 3.0.0Creative Commons Attribution 3.02026-07-131,0021,0174.3 MB
instances

Attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. It is not possible to create and attach a disk at the same time. For more information, readAdding a persistent disk to your instance.

post/projects/{project}/zones/{zone}/instances/{instance}/attachDisk

Path parameters

projectstring required

Project ID for this request.

zonestring required

The name of the zone for this request.

instancestring required

The instance name for this request.

Query parameters

forceAttachboolean

Whether to force attach the regional disk even if it's currently attached to another instance. If you try to force attach a zonal disk to an instance, you will receive an error.

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

interface'NVME' | 'SCSI'

Specifies the disk interface to use for attaching this disk, which is either SCSI or NVME. For most machine types, the default is SCSI. Local SSDs can use either NVME or SCSI. In certain configurations, persistent disks can use NVMe. For more information, seeAbout persistent disks.

kindstring

Output only. [Output Only] Type of the resource. Alwayscompute#attachedDisk for attached disks.

indexinteger

Output only. [Output Only] A zero-based index to this disk, where 0 is reserved for the boot disk. If you have many disks attached to an instance, each disk would have a unique index number.

deviceNamestring

Specifies a unique device name of your choice that is reflected into the/dev/disk/by-id/google-* tree of a Linux operating system running within the instance. This name can be used to reference the device for mounting, resizing, and so on, from within the instance.

If not specified, the server chooses a default device name to apply to this disk, in the form persistent-disk-x, where x is a number assigned by Google Compute Engine. This field is only applicable for persistent disks.

diskSizeGbstring int64

The size of the disk in GB.

autoDeleteboolean

Specifies whether the disk will be auto-deleted when the instance is deleted (but not when the disk is detached from the instance).

mode'READ_ONLY' | 'READ_WRITE'

The mode in which to attach this disk, either READ_WRITE orREAD_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode.

savedState'DISK_SAVED_STATE_UNSPECIFIED' | 'PRESERVED'

Output only. For LocalSSD disks on VM Instances in STOPPED or SUSPENDED state, this field is set to PRESERVED if the LocalSSD data has been saved to a persistent location by customer request. (see the discard_local_ssd option on Stop/Suspend). Read-only in the api.

sourcestring

Specifies a valid partial or full URL to an existing Persistent Disk resource. When creating a new instance boot disk, one ofinitializeParams.sourceImage orinitializeParams.sourceSnapshot or disks.source is required.

If desired, you can also attach existing non-root persistent disks using this property. This field is only applicable for persistent disks.

Note that for InstanceTemplate, specify the disk name for zonal disk, and the URL for regional disk.

architecture'ARCHITECTURE_UNSPECIFIED' | 'ARM64' | 'X86_64'

Output only. [Output Only] The architecture of the attached disk. Valid values are ARM64 or X86_64.

type'PERSISTENT' | 'SCRATCH'

Specifies the type of the disk, either SCRATCH orPERSISTENT. If not specified, the default isPERSISTENT.

forceAttachboolean

[Input Only] Whether to force attach the regional disk even if it's currently attached to another instance. If you try to force attach a zonal disk to an instance, you will receive an error.

licensesstring[]

Output only. [Output Only] Any valid publicly visible licenses.

bootboolean

Indicates that this is a boot disk. The virtual machine will use the first partition of the disk for its root filesystem.

Response

Successful response