---
title: "POST /projects/{project}/zones/{zone}/instances/{instance}/attachDisk"
method: POST
path: "/projects/{project}/zones/{zone}/instances/{instance}/attachDisk"
tags: ["instances"]
---

# POST /projects/{project}/zones/{zone}/instances/{instance}/attachDisk

`POST /projects/{project}/zones/{zone}/instances/{instance}/attachDisk`

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.

## Path parameters

- `project` string, required
- `zone` string, required
- `instance` string, required

## Query parameters

- `forceAttach` boolean
- `requestId` string

## Request body

- AttachedDisk — An instance-attached disk resource.
  - `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.
  - `guestOsFeatures` GuestOsFeature[] — A list of features to enable on the guest operating system. Applicable only for bootable images. Read Enabling guest operating system features to see a list of available options.
    - `type` 'BARE_METAL_LINUX_COMPATIBLE' | 'CCA_CAPABLE' | 'FEATURE_TYPE_UNSPECIFIED' | 'GVNIC' | 'IDPF' | 'MULTI_IP_SUBNET' | 'SECURE_BOOT' | 'SEV_CAPABLE' | 'SEV_LIVE_MIGRATABLE' | 'SEV_LIVE_MIGRATABLE_V2' | 'SEV_SNP_CAPABLE' | 'SNP_SVSM_CAPABLE' | 'TDX_CAPABLE' | 'UEFI_COMPATIBLE' | 'VIRTIO_SCSI_MULTIQUEUE' | 'WINDOWS' — The ID of a supported feature. To add multiple values, use commas to separate values. Set to one or more of the following values: - VIRTIO_SCSI_MULTIQUEUE - WINDOWS - MULTI_IP_SUBNET - UEFI_COMPATIBLE - GVNIC - SEV_CAPABLE - SUSPEND_RESUME_COMPATIBLE - SEV_LIVE_MIGRATABLE_V2 - SEV_SNP_CAPABLE - TDX_CAPABLE - IDPF - SNP_SVSM_CAPABLE - CCA_CAPABLE For more information, see Enabling guest operating system features.
  - `initializeParams` AttachedDiskInitializeParams — [Input Only] Specifies the parameters for a new disk that will be created alongside the new instance. Use initialization parameters to create boot disks or local SSDs attached to the new instance. This field is persisted and returned for instanceTemplate and not returned in the context of instance. This property is mutually exclusive with the source property; you can only define one or the other, but not both.
    - `provisionedIops` string, int64 — Indicates how many IOPS to provision for the disk. This sets the number of I/O operations per second that the disk can handle. Values must be between 10,000 and 120,000. For more details, see theExtreme persistent disk documentation.
    - `provisionedThroughput` string, int64 — Indicates how much throughput to provision for the disk. This sets the number of throughput mb per second that the disk can handle. Values must greater than or equal to 1.
    - `sourceImageEncryptionKey` CustomerEncryptionKey
      - `kmsKeyName` string — The name of the encryption key that is stored in Google Cloud KMS. For example: "kmsKeyName": "projects/kms_project_id/locations/region/keyRings/ key_region/cryptoKeys/key The fully-qualifed key name may be returned for resource GET requests. For example: "kmsKeyName": "projects/kms_project_id/locations/region/keyRings/ key_region/cryptoKeys/key /cryptoKeyVersions/1
      - `sha256` string — [Output only] TheRFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this resource.
      - `rawKey` string — Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource. You can provide either the rawKey or thersaEncryptedKey. For example: "rawKey": "SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0="
      - `kmsKeyServiceAccount` string — The service account being used for the encryption request for the given KMS key. If absent, the Compute Engine default service account is used. For example: "kmsKeyServiceAccount": "name@project_id.iam.gserviceaccount.com/
      - `rsaEncryptedKey` string — Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied encryption key to either encrypt or decrypt this resource. You can provide either the rawKey or thersaEncryptedKey. For example: "rsaEncryptedKey": "ieCx/NcW06PcT7Ep1X6LUTc/hLvUDYyzSZPPVCVPTVEohpeHASqC8uw5TzyO9U+Fka9JFH z0mBibXUInrC/jEk014kCK/NPjYgEMOyssZ4ZINPKxlUh2zn1bV+MCaTICrdmuSBTWlUUiFoD D6PYznLwh8ZNdaheCeZ8ewEXgFQ8V+sDroLaN3Xs3MDTXQEMMoNUXMCZEIpg9Vtp9x2oe==" The key must meet the following requirements before you can provide it to Compute Engine: 1. The key is wrapped using a RSA public key certificate provided by Google. 2. After being wrapped, the key must be encoded in RFC 4648 base64 encoding. Gets the RSA public key certificate provided by Google at: https://cloud-certs.storage.googleapis.com/google-cloud-csek-ingress.pem
    - `licenses` string[] — A list of publicly visible licenses. Reserved for Google's use.
    - `resourceManagerTags` object — Input only. Resource manager tags to be bound to the disk. Tag keys and values have the same definition as resource manager tags. Keys and values can be either in numeric format, such as `tagKeys/{tag_key_id}` and `tagValues/{tag_value_id}` or in namespaced format such as `{org_id|project_id}/{tag_key_short_name}` and `{tag_value_short_name}`. The field is ignored (both PUT & PATCH) when empty.
    - `diskName` string — Specifies the disk name. If not specified, the default is to use the name of the instance. If a disk with the same name already exists in the given region, the existing disk is attached to the new instance and the new disk is not created.
    - `sourceSnapshot` string — The source snapshot to create this disk. When creating a new instance boot disk, one of initializeParams.sourceSnapshot orinitializeParams.sourceImage or disks.source is required. To create a disk with a snapshot that you created, specify the snapshot name in the following format: global/snapshots/my-backup If the source snapshot is deleted later, this field will not be set. Note: You cannot create VMs in bulk using a snapshot as the source. Use an image instead when you create VMs using the bulk insert method.
    - `resourcePolicies` string[] — Resource policies applied to this disk for automatic snapshot creations. Specified using the full or partial URL. For instance template, specify only the resource policy name.
    - `onUpdateAction` 'RECREATE_DISK' | 'RECREATE_DISK_IF_SOURCE_CHANGED' | 'USE_EXISTING_DISK' — Specifies which action to take on instance update with this disk. Default is to use the existing disk.
    - `architecture` 'ARCHITECTURE_UNSPECIFIED' | 'ARM64' | 'X86_64' — The architecture of the attached disk. Valid values are arm64 or x86_64.
    - `diskType` string
    - `description` string — An optional description. Provide this property when creating the disk.
    - `sourceSnapshotEncryptionKey` CustomerEncryptionKey
      - `kmsKeyName` string — The name of the encryption key that is stored in Google Cloud KMS. For example: "kmsKeyName": "projects/kms_project_id/locations/region/keyRings/ key_region/cryptoKeys/key The fully-qualifed key name may be returned for resource GET requests. For example: "kmsKeyName": "projects/kms_project_id/locations/region/keyRings/ key_region/cryptoKeys/key /cryptoKeyVersions/1
      - `sha256` string — [Output only] TheRFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this resource.
      - `rawKey` string — Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource. You can provide either the rawKey or thersaEncryptedKey. For example: "rawKey": "SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0="
      - `kmsKeyServiceAccount` string — The service account being used for the encryption request for the given KMS key. If absent, the Compute Engine default service account is used. For example: "kmsKeyServiceAccount": "name@project_id.iam.gserviceaccount.com/
      - `rsaEncryptedKey` string — Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied encryption key to either encrypt or decrypt this resource. You can provide either the rawKey or thersaEncryptedKey. For example: "rsaEncryptedKey": "ieCx/NcW06PcT7Ep1X6LUTc/hLvUDYyzSZPPVCVPTVEohpeHASqC8uw5TzyO9U+Fka9JFH z0mBibXUInrC/jEk014kCK/NPjYgEMOyssZ4ZINPKxlUh2zn1bV+MCaTICrdmuSBTWlUUiFoD D6PYznLwh8ZNdaheCeZ8ewEXgFQ8V+sDroLaN3Xs3MDTXQEMMoNUXMCZEIpg9Vtp9x2oe==" The key must meet the following requirements before you can provide it to Compute Engine: 1. The key is wrapped using a RSA public key certificate provided by Google. 2. After being wrapped, the key must be encoded in RFC 4648 base64 encoding. Gets the RSA public key certificate provided by Google at: https://cloud-certs.storage.googleapis.com/google-cloud-csek-ingress.pem
    - `labels` object — Labels to apply to this disk. These can be later modified by thedisks.setLabels method. This field is only applicable for persistent disks.
    - `sourceImage` string — The source image to create this disk. When creating a new instance boot disk, one of initializeParams.sourceImage orinitializeParams.sourceSnapshot or disks.source is required. To create a disk with one of the public operating system images, specify the image by its family name. For example, specifyfamily/debian-9 to use the latest Debian 9 image: projects/debian-cloud/global/images/family/debian-9 Alternatively, use a specific version of a public operating system image: projects/debian-cloud/global/images/debian-9-stretch-vYYYYMMDD To create a disk with a custom image that you created, specify the image name in the following format: global/images/my-custom-image You can also specify a custom image by its image family, which returns the latest version of the image in that family. Replace the image name with family/family-name: global/images/family/my-image-family If the source image is deleted later, this field will not be set.
    - `diskSizeGb` string, int64 — Specifies the size of the disk in base-2 GB. The size must be at least 10 GB. If you specify a sourceImage, which is required for boot disks, the default size is the size of the sourceImage. If you do not specify a sourceImage, the default disk size is 500 GB.
    - `replicaZones` string[] — Required for each regional disk associated with the instance. Specify the URLs of the zones where the disk should be replicated to. You must provide exactly two replica zones, and one zone must be the same as the instance zone.
    - `enableConfidentialCompute` boolean — Whether this disk is using confidential compute mode.
    - `storagePool` string — The storage pool in which the new disk is created. You can provide this as a partial or full URL to the resource. For example, the following are valid values: - https://www.googleapis.com/compute/v1/projects/project/zones/zone/storagePools/storagePool - projects/project/zones/zone/storagePools/storagePool - zones/zone/storagePools/storagePool
  - `kind` string — Output only. [Output Only] Type of the resource. Alwayscompute#attachedDisk for attached disks.
  - `index` integer — 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.
  - `deviceName` string — 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.
  - `diskSizeGb` string, int64 — The size of the disk in GB.
  - `shieldedInstanceInitialState` InitialStateConfig — Initial State for shielded instance, these are public keys which are safe to store in public
    - `keks` FileContentBuffer[] — The Key Exchange Key (KEK).
      - `content` string, byte — The raw content in the secure keys file.
      - `fileType` 'BIN' | 'UNDEFINED' | 'X509' — The file type of source file.
    - `dbxs` FileContentBuffer[] — The forbidden key database (dbx).
      - `content` string, byte — The raw content in the secure keys file.
      - `fileType` 'BIN' | 'UNDEFINED' | 'X509' — The file type of source file.
    - `pk` FileContentBuffer
      - `content` string, byte — The raw content in the secure keys file.
      - `fileType` 'BIN' | 'UNDEFINED' | 'X509' — The file type of source file.
    - `dbs` FileContentBuffer[] — The Key Database (db).
      - `content` string, byte — The raw content in the secure keys file.
      - `fileType` 'BIN' | 'UNDEFINED' | 'X509' — The file type of source file.
  - `autoDelete` boolean — 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.
  - `source` string — 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.
  - `forceAttach` boolean — [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.
  - `diskEncryptionKey` CustomerEncryptionKey
    - `kmsKeyName` string — The name of the encryption key that is stored in Google Cloud KMS. For example: "kmsKeyName": "projects/kms_project_id/locations/region/keyRings/ key_region/cryptoKeys/key The fully-qualifed key name may be returned for resource GET requests. For example: "kmsKeyName": "projects/kms_project_id/locations/region/keyRings/ key_region/cryptoKeys/key /cryptoKeyVersions/1
    - `sha256` string — [Output only] TheRFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this resource.
    - `rawKey` string — Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource. You can provide either the rawKey or thersaEncryptedKey. For example: "rawKey": "SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0="
    - `kmsKeyServiceAccount` string — The service account being used for the encryption request for the given KMS key. If absent, the Compute Engine default service account is used. For example: "kmsKeyServiceAccount": "name@project_id.iam.gserviceaccount.com/
    - `rsaEncryptedKey` string — Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied encryption key to either encrypt or decrypt this resource. You can provide either the rawKey or thersaEncryptedKey. For example: "rsaEncryptedKey": "ieCx/NcW06PcT7Ep1X6LUTc/hLvUDYyzSZPPVCVPTVEohpeHASqC8uw5TzyO9U+Fka9JFH z0mBibXUInrC/jEk014kCK/NPjYgEMOyssZ4ZINPKxlUh2zn1bV+MCaTICrdmuSBTWlUUiFoD D6PYznLwh8ZNdaheCeZ8ewEXgFQ8V+sDroLaN3Xs3MDTXQEMMoNUXMCZEIpg9Vtp9x2oe==" The key must meet the following requirements before you can provide it to Compute Engine: 1. The key is wrapped using a RSA public key certificate provided by Google. 2. After being wrapped, the key must be encoded in RFC 4648 base64 encoding. Gets the RSA public key certificate provided by Google at: https://cloud-certs.storage.googleapis.com/google-cloud-csek-ingress.pem
  - `licenses` string[] — Output only. [Output Only] Any valid publicly visible licenses.
  - `boot` boolean — Indicates that this is a boot disk. The virtual machine will use the first partition of the disk for its root filesystem.

## Response `200`

Successful response

---

[API](https://skmtc.net/google/apis/compute.md) · [All operations](https://skmtc.net/google/apis/compute/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/google/compute/versions/6120ed8969d4/schema)
