2014-08-26 21:50:29 +00:00
|
|
|
---
|
|
|
|
layout: "google"
|
|
|
|
page_title: "Google: google_compute_disk"
|
2015-10-23 14:10:41 +00:00
|
|
|
sidebar_current: "docs-google-compute-disk"
|
2014-10-22 03:21:56 +00:00
|
|
|
description: |-
|
|
|
|
Creates a new persistent disk within GCE, based on another disk.
|
2014-08-26 21:50:29 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# google\_compute\_disk
|
|
|
|
|
2017-07-28 18:05:48 +00:00
|
|
|
Creates a new persistent disk within GCE, based on another disk. For more information see
|
|
|
|
[the official documentation](https://cloud.google.com/compute/docs/disks/add-persistent-disk)
|
|
|
|
and
|
|
|
|
[API](https://cloud.google.com/compute/docs/reference/latest/disks).
|
2014-08-26 21:50:29 +00:00
|
|
|
|
2017-03-29 09:37:36 +00:00
|
|
|
~> **Note:** All arguments including the disk encryption key will be stored in the raw state as plain-text.
|
|
|
|
[Read more about sensitive data in state](/docs/state/sensitive-data.html).
|
|
|
|
|
2014-08-26 21:50:29 +00:00
|
|
|
## Example Usage
|
|
|
|
|
2017-04-17 10:17:54 +00:00
|
|
|
```hcl
|
2014-08-26 21:50:29 +00:00
|
|
|
resource "google_compute_disk" "default" {
|
2016-04-10 21:34:15 +00:00
|
|
|
name = "test-disk"
|
|
|
|
type = "pd-ssd"
|
|
|
|
zone = "us-central1-a"
|
2017-06-14 21:31:40 +00:00
|
|
|
image = "debian-8-jessie-v20170523"
|
2017-08-18 23:10:47 +00:00
|
|
|
labels {
|
|
|
|
environment = "dev"
|
|
|
|
}
|
2014-08-26 21:50:29 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
|
|
|
* `name` - (Required) A unique name for the resource, required by GCE.
|
|
|
|
Changing this forces a new resource to be created.
|
|
|
|
|
|
|
|
* `zone` - (Required) The zone where this disk will be available.
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
- - -
|
|
|
|
|
2017-01-18 13:49:48 +00:00
|
|
|
* `disk_encryption_key_raw` - (Optional) A 256-bit [customer-supplied encryption key]
|
|
|
|
(https://cloud.google.com/compute/docs/disks/customer-supplied-encryption),
|
|
|
|
encoded in [RFC 4648 base64](https://tools.ietf.org/html/rfc4648#section-4)
|
|
|
|
to encrypt this disk.
|
|
|
|
|
2017-03-14 05:15:37 +00:00
|
|
|
* `image` - (Optional) The image from which to initialize this disk. This can be
|
2017-06-14 21:31:40 +00:00
|
|
|
one of: the image's `self_link`, of a full name and version, e.g.
|
|
|
|
`debian-8-jessie-v20170523`
|
2016-04-10 21:34:15 +00:00
|
|
|
|
|
|
|
* `project` - (Optional) The project in which the resource belongs. If it
|
|
|
|
is not provided, the provider project is used.
|
2014-08-26 21:50:29 +00:00
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
* `size` - (Optional) The size of the image in gigabytes. If not specified, it
|
|
|
|
will inherit the size of its base image.
|
2015-04-08 11:41:47 +00:00
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
* `snapshot` - (Optional) Name of snapshot from which to initialize this disk.
|
2014-08-26 21:50:29 +00:00
|
|
|
|
2014-10-07 04:59:09 +00:00
|
|
|
* `type` - (Optional) The GCE disk type.
|
|
|
|
|
2017-08-18 23:10:47 +00:00
|
|
|
* `labels` - (Optional) A set of key/value label pairs to assign to the image.
|
|
|
|
|
2014-08-26 21:50:29 +00:00
|
|
|
## Attributes Reference
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
In addition to the arguments listed above, the following computed attributes are
|
|
|
|
exported:
|
2014-08-26 21:50:29 +00:00
|
|
|
|
2017-01-18 13:49:48 +00:00
|
|
|
* `disk_encryption_key_sha256` - The [RFC 4648 base64]
|
|
|
|
(https://tools.ietf.org/html/rfc4648#section-4) encoded SHA-256 hash of the
|
|
|
|
[customer-supplied encryption key](https://cloud.google.com/compute/docs/disks/customer-supplied-encryption)
|
|
|
|
that protects this resource.
|
|
|
|
|
2016-04-10 21:34:15 +00:00
|
|
|
* `self_link` - The URI of the created resource.
|
2017-06-14 00:46:50 +00:00
|
|
|
|
2017-08-18 23:10:47 +00:00
|
|
|
* `users` - The Users of the created resource.
|
|
|
|
|
|
|
|
* `label_fingerprint` - The fingerprint of the assigned labels.
|
2017-06-30 10:36:39 +00:00
|
|
|
|
2017-06-14 00:46:50 +00:00
|
|
|
## Import
|
|
|
|
|
|
|
|
Disks can be imported using the `name`, e.g.
|
|
|
|
|
|
|
|
```
|
|
|
|
$ terraform import google_compute_disk.default test-disk
|
|
|
|
```
|