mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-09-07 09:36:44 +00:00
195 lines
6.2 KiB
Markdown
195 lines
6.2 KiB
Markdown
---
|
|
# ----------------------------------------------------------------------------
|
|
#
|
|
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
|
|
#
|
|
# ----------------------------------------------------------------------------
|
|
#
|
|
# This file is automatically generated by Magic Modules and manual
|
|
# changes will be clobbered when the file is regenerated.
|
|
#
|
|
# Please read more about how to change this file in
|
|
# .github/CONTRIBUTING.md.
|
|
#
|
|
# ----------------------------------------------------------------------------
|
|
layout: "google"
|
|
page_title: "Google: google_compute_snapshot"
|
|
sidebar_current: "docs-google-compute-snapshot"
|
|
description: |-
|
|
Represents a Persistent Disk Snapshot resource.
|
|
---
|
|
|
|
# google\_compute\_snapshot
|
|
|
|
Represents a Persistent Disk Snapshot resource.
|
|
|
|
Use snapshots to back up data from your persistent disks. Snapshots are
|
|
different from public images and custom images, which are used primarily
|
|
to create instances or configure instance templates. Snapshots are useful
|
|
for periodic backup of the data on your persistent disks. You can create
|
|
snapshots from persistent disks even while they are attached to running
|
|
instances.
|
|
|
|
Snapshots are incremental, so you can create regular snapshots on a
|
|
persistent disk faster and at a much lower cost than if you regularly
|
|
created a full image of the disk.
|
|
|
|
|
|
To get more information about Snapshot, see:
|
|
|
|
* [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/snapshots)
|
|
* How-to Guides
|
|
* [Official Documentation](https://cloud.google.com/compute/docs/disks/create-snapshots)
|
|
|
|
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
|
|
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=snapshot_basic&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
|
|
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
|
|
</a>
|
|
</div>
|
|
## Example Usage - Snapshot Basic
|
|
|
|
|
|
```hcl
|
|
resource "google_compute_snapshot" "snapshot" {
|
|
name = "my-snapshot"
|
|
source_disk = "${google_compute_disk.persistent.name}"
|
|
zone = "us-central1-a"
|
|
labels = {
|
|
my_label = "value"
|
|
}
|
|
}
|
|
|
|
data "google_compute_image" "debian" {
|
|
family = "debian-9"
|
|
project = "debian-cloud"
|
|
}
|
|
|
|
resource "google_compute_disk" "persistent" {
|
|
name = "debian-disk"
|
|
image = "${data.google_compute_image.debian.self_link}"
|
|
size = 10
|
|
type = "pd-ssd"
|
|
zone = "us-central1-a"
|
|
}
|
|
```
|
|
|
|
## Argument Reference
|
|
|
|
The following arguments are supported:
|
|
|
|
|
|
* `name` -
|
|
(Required)
|
|
Name of the resource; provided by the client when the resource is
|
|
created. The name must be 1-63 characters long, and comply with
|
|
RFC1035. 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.
|
|
|
|
* `source_disk` -
|
|
(Required)
|
|
A reference to the disk used to create this snapshot.
|
|
|
|
|
|
- - -
|
|
|
|
|
|
* `description` -
|
|
(Optional)
|
|
An optional description of this resource.
|
|
|
|
* `labels` -
|
|
(Optional)
|
|
Labels to apply to this Snapshot.
|
|
|
|
* `zone` -
|
|
(Optional)
|
|
A reference to the zone where the disk is hosted.
|
|
|
|
* `snapshot_encryption_key` -
|
|
(Optional)
|
|
The customer-supplied encryption key of the snapshot. Required if the
|
|
source snapshot is protected by a customer-supplied encryption key. Structure is documented below.
|
|
|
|
* `source_disk_encryption_key` -
|
|
(Optional)
|
|
The customer-supplied encryption key of the source snapshot. Required
|
|
if the source snapshot is protected by a customer-supplied encryption
|
|
key. Structure is documented below.
|
|
* `project` - (Optional) The ID of the project in which the resource belongs.
|
|
If it is not provided, the provider project is used.
|
|
|
|
|
|
The `snapshot_encryption_key` block supports:
|
|
|
|
* `raw_key` -
|
|
(Optional)
|
|
Specifies a 256-bit customer-supplied encryption key, encoded in
|
|
RFC 4648 base64 to either encrypt or decrypt this resource.
|
|
|
|
* `sha256` -
|
|
The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied
|
|
encryption key that protects this resource.
|
|
|
|
The `source_disk_encryption_key` block supports:
|
|
|
|
* `raw_key` -
|
|
(Optional)
|
|
Specifies a 256-bit customer-supplied encryption key, encoded in
|
|
RFC 4648 base64 to either encrypt or decrypt this resource.
|
|
|
|
## Attributes Reference
|
|
|
|
In addition to the arguments listed above, the following computed attributes are exported:
|
|
|
|
|
|
* `creation_timestamp` -
|
|
Creation timestamp in RFC3339 text format.
|
|
|
|
* `snapshot_id` -
|
|
The unique identifier for the resource.
|
|
|
|
* `disk_size_gb` -
|
|
Size of the snapshot, specified in GB.
|
|
|
|
* `storage_bytes` -
|
|
A size of the the storage used by the snapshot. As snapshots share
|
|
storage, this number is expected to change with snapshot
|
|
creation/deletion.
|
|
|
|
* `licenses` -
|
|
A list of public visible licenses that apply to this snapshot. This
|
|
can be because the original image had licenses attached (such as a
|
|
Windows image). snapshotEncryptionKey nested object Encrypts the
|
|
snapshot using a customer-supplied encryption key.
|
|
|
|
* `label_fingerprint` -
|
|
The fingerprint used for optimistic locking of this resource. Used
|
|
internally during updates.
|
|
* `self_link` - The URI of the created resource.
|
|
|
|
|
|
## Timeouts
|
|
|
|
This resource provides the following
|
|
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:
|
|
|
|
- `create` - Default is 5 minutes.
|
|
- `update` - Default is 5 minutes.
|
|
- `delete` - Default is 5 minutes.
|
|
|
|
## Import
|
|
|
|
Snapshot can be imported using any of these accepted formats:
|
|
|
|
```
|
|
$ terraform import google_compute_snapshot.default projects/{{project}}/global/snapshots/{{name}}
|
|
$ terraform import google_compute_snapshot.default {{project}}/{{name}}
|
|
$ terraform import google_compute_snapshot.default {{name}}
|
|
```
|
|
|
|
-> If you're importing a resource with beta features, make sure to include `-provider=google-beta"
|
|
as an argument so that Terraform uses the correct provider to import your resource.
|