terraform-provider-google/website/docs/r/compute_attached_disk.html.markdown
Chris Stephens afcbb859ca
Attached disk resource (#1957)
* Adding resource_attached_disk

This is a resource which will allow joining a arbitrary compute disk
to a compute instance. This will enable dynamic numbers of disks to
be associated by using counts.
2018-09-11 13:08:14 -07:00

3.2 KiB

layout page_title sidebar_current description
google Google: google_compute_attached_disk docs-google-compute-attached-disk Resource that allows attaching existing persistent disks to compute instances.

google_compute_attached_disk

Persistent disks can be attached to a compute instance using the attached_disk section within the compute instance configuration. However there may be situations where managing the attached disks via the compute instance config isn't preferable or possible, such as attaching dynamic numbers of disks using the count variable.

To get more information about attaching disks, see:

Example Usage

resource "google_compute_attached_disk" "default" {
  disk = "${google_compute_disk.default.self_link}"
  instance = "${google_compute_instance.default.self_link}"
}

Argument Reference

The following arguments are supported:

  • instance - (Required) name or self_link of the compute instance that the disk will be attached to. If the self_link is provided then zone and project are extracted from the self link. If only the name is used then zone and project must be defined as properties on the resource or provider.

  • disk - (Required) name or self_link of the disk that will be attached.


  • project - (Optional) The project that the referenced compute instance is a part of. If instance is referenced by its self_link the project defined in the link will take precedence.

  • zone - (Optional) The zone that the referenced compute instance is located within. If instance is referenced by its self_link the zone defined in the link will take precedence.

  • device_name - (Optional) 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-disks-x, where x is a number assigned by Google Compute Engine.

  • mode - (Optional) The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If not specified, the default is to attach the disk in READ_WRITE mode.

    Possible values: "READ_ONLY" "READ_WRITE"

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 5 minutes.
  • delete - Default is 5 minutes.

Import

Attached Disk can be imported the following ways:

$ terraform import google_compute_disk.default projects/{{project}}/zones/{{zone}}/disks/{{instance.name}}:{{disk.name}}
$ terraform import google_compute_disk.default {{project}}/{{zone}}/{{instance.name}}:{{disk.name}}