Snapshot

class Snapshot : KotlinCustomResource

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:

Warning: All arguments including snapshot_encryption_key.raw_key and source_disk_encryption_key.raw_key will be stored in the raw state as plain-text.

Example Usage

Snapshot Basic

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.ComputeFunctions;
import com.pulumi.gcp.compute.inputs.GetImageArgs;
import com.pulumi.gcp.compute.Disk;
import com.pulumi.gcp.compute.DiskArgs;
import com.pulumi.gcp.compute.Snapshot;
import com.pulumi.gcp.compute.SnapshotArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var debian = ComputeFunctions.getImage(GetImageArgs.builder()
.family("debian-11")
.project("debian-cloud")
.build());
var persistent = new Disk("persistent", DiskArgs.builder()
.image(debian.applyValue(getImageResult -> getImageResult.selfLink()))
.size(10)
.type("pd-ssd")
.zone("us-central1-a")
.build());
var snapshot = new Snapshot("snapshot", SnapshotArgs.builder()
.sourceDisk(persistent.id())
.zone("us-central1-a")
.labels(Map.of("my_label", "value"))
.storageLocations("us-central1")
.build());
}
}

Snapshot Chainname

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.ComputeFunctions;
import com.pulumi.gcp.compute.inputs.GetImageArgs;
import com.pulumi.gcp.compute.Disk;
import com.pulumi.gcp.compute.DiskArgs;
import com.pulumi.gcp.compute.Snapshot;
import com.pulumi.gcp.compute.SnapshotArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var debian = ComputeFunctions.getImage(GetImageArgs.builder()
.family("debian-11")
.project("debian-cloud")
.build());
var persistent = new Disk("persistent", DiskArgs.builder()
.image(debian.applyValue(getImageResult -> getImageResult.selfLink()))
.size(10)
.type("pd-ssd")
.zone("us-central1-a")
.build());
var snapshot = new Snapshot("snapshot", SnapshotArgs.builder()
.sourceDisk(persistent.id())
.zone("us-central1-a")
.chainName("snapshot-chain")
.labels(Map.of("my_label", "value"))
.storageLocations("us-central1")
.build());
}
}

Import

Snapshot can be imported using any of these accepted formats

$ pulumi import gcp:compute/snapshot:Snapshot default projects/{{project}}/global/snapshots/{{name}}
$ pulumi import gcp:compute/snapshot:Snapshot default {{project}}/{{name}}
$ pulumi import gcp:compute/snapshot:Snapshot default {{name}}

Properties

Link copied to clipboard
val chainName: Output<String>?

Creates the new snapshot in the snapshot chain labeled with the specified name. The chain name must be 1-63 characters long and comply with RFC1035. This is an uncommon option only for advanced service owners who needs to create separate snapshot chains, for example, for chargeback tracking. When you describe your snapshot resource, this field is visible only if it has a non-empty value.

Link copied to clipboard

Creation timestamp in RFC3339 text format.

Link copied to clipboard
val description: Output<String>?

An optional description of this resource.

Link copied to clipboard
val diskSizeGb: Output<Int>

Size of the snapshot, specified in GB.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard

The fingerprint used for optimistic locking of this resource. Used internally during updates.

Link copied to clipboard
val labels: Output<Map<String, String>>?

Labels to apply to this Snapshot.

Link copied to clipboard
val licenses: Output<List<String>>

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.

Link copied to clipboard
val name: Output<String>

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? 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.

Link copied to clipboard
val project: Output<String>

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val selfLink: Output<String>

The URI of the created resource.

Link copied to clipboard

Encrypts the snapshot using a customer-supplied encryption key. After you encrypt a snapshot using a customer-supplied key, you must provide the same key if you use the snapshot later. For example, you must provide the encryption key when you create a disk from the encrypted snapshot in a future request. Customer-supplied encryption keys do not protect access to metadata of the snapshot. If you do not provide an encryption key when creating the snapshot, then the snapshot will be encrypted using an automatically generated key and you do not need to provide a key to use the snapshot later. Structure is documented below.

Link copied to clipboard
val snapshotId: Output<Int>

The unique identifier for the resource.

Link copied to clipboard
val sourceDisk: Output<String>

A reference to the disk used to create this snapshot.

Link copied to clipboard

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.

Link copied to clipboard
val storageBytes: Output<Int>

A size of the storage used by the snapshot. As snapshots share storage, this number is expected to change with snapshot creation/deletion.

Link copied to clipboard

Cloud Storage bucket storage location of the snapshot (regional or multi-regional).

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val zone: Output<String>

A reference to the zone where the disk is hosted.