com.pulumi.gcp.compute.kotlin.Snapshot.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-gcp-kotlin Show documentation
Show all versions of pulumi-gcp-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.compute.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.compute.kotlin.outputs.SnapshotSnapshotEncryptionKey
import com.pulumi.gcp.compute.kotlin.outputs.SnapshotSourceDiskEncryptionKey
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import com.pulumi.gcp.compute.kotlin.outputs.SnapshotSnapshotEncryptionKey.Companion.toKotlin as snapshotSnapshotEncryptionKeyToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.SnapshotSourceDiskEncryptionKey.Companion.toKotlin as snapshotSourceDiskEncryptionKeyToKotlin
/**
* Builder for [Snapshot].
*/
@PulumiTagMarker
public class SnapshotResourceBuilder internal constructor() {
public var name: String? = null
public var args: SnapshotArgs = SnapshotArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend SnapshotArgsBuilder.() -> Unit) {
val builder = SnapshotArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
}
internal fun build(): Snapshot {
val builtJavaResource = com.pulumi.gcp.compute.Snapshot(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return Snapshot(builtJavaResource)
}
}
/**
* 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)
* ## Example Usage
* ### Snapshot Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const debian = gcp.compute.getImage({
* family: "debian-11",
* project: "debian-cloud",
* });
* const persistent = new gcp.compute.Disk("persistent", {
* name: "debian-disk",
* image: debian.then(debian => debian.selfLink),
* size: 10,
* type: "pd-ssd",
* zone: "us-central1-a",
* });
* const snapshot = new gcp.compute.Snapshot("snapshot", {
* name: "my-snapshot",
* sourceDisk: persistent.id,
* zone: "us-central1-a",
* labels: {
* my_label: "value",
* },
* storageLocations: ["us-central1"],
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* debian = gcp.compute.get_image(family="debian-11",
* project="debian-cloud")
* persistent = gcp.compute.Disk("persistent",
* name="debian-disk",
* image=debian.self_link,
* size=10,
* type="pd-ssd",
* zone="us-central1-a")
* snapshot = gcp.compute.Snapshot("snapshot",
* name="my-snapshot",
* source_disk=persistent.id,
* zone="us-central1-a",
* labels={
* "my_label": "value",
* },
* storage_locations=["us-central1"])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var debian = Gcp.Compute.GetImage.Invoke(new()
* {
* Family = "debian-11",
* Project = "debian-cloud",
* });
* var persistent = new Gcp.Compute.Disk("persistent", new()
* {
* Name = "debian-disk",
* Image = debian.Apply(getImageResult => getImageResult.SelfLink),
* Size = 10,
* Type = "pd-ssd",
* Zone = "us-central1-a",
* });
* var snapshot = new Gcp.Compute.Snapshot("snapshot", new()
* {
* Name = "my-snapshot",
* SourceDisk = persistent.Id,
* Zone = "us-central1-a",
* Labels =
* {
* { "my_label", "value" },
* },
* StorageLocations = new[]
* {
* "us-central1",
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* debian, err := compute.LookupImage(ctx, &compute.LookupImageArgs{
* Family: pulumi.StringRef("debian-11"),
* Project: pulumi.StringRef("debian-cloud"),
* }, nil)
* if err != nil {
* return err
* }
* persistent, err := compute.NewDisk(ctx, "persistent", &compute.DiskArgs{
* Name: pulumi.String("debian-disk"),
* Image: pulumi.String(debian.SelfLink),
* Size: pulumi.Int(10),
* Type: pulumi.String("pd-ssd"),
* Zone: pulumi.String("us-central1-a"),
* })
* if err != nil {
* return err
* }
* _, err = compute.NewSnapshot(ctx, "snapshot", &compute.SnapshotArgs{
* Name: pulumi.String("my-snapshot"),
* SourceDisk: persistent.ID(),
* Zone: pulumi.String("us-central1-a"),
* Labels: pulumi.StringMap{
* "my_label": pulumi.String("value"),
* },
* StorageLocations: pulumi.StringArray{
* pulumi.String("us-central1"),
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* 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()
* .name("debian-disk")
* .image(debian.applyValue(getImageResult -> getImageResult.selfLink()))
* .size(10)
* .type("pd-ssd")
* .zone("us-central1-a")
* .build());
* var snapshot = new Snapshot("snapshot", SnapshotArgs.builder()
* .name("my-snapshot")
* .sourceDisk(persistent.id())
* .zone("us-central1-a")
* .labels(Map.of("my_label", "value"))
* .storageLocations("us-central1")
* .build());
* }
* }
* ```
* ```yaml
* resources:
* snapshot:
* type: gcp:compute:Snapshot
* properties:
* name: my-snapshot
* sourceDisk: ${persistent.id}
* zone: us-central1-a
* labels:
* my_label: value
* storageLocations:
* - us-central1
* persistent:
* type: gcp:compute:Disk
* properties:
* name: debian-disk
* image: ${debian.selfLink}
* size: 10
* type: pd-ssd
* zone: us-central1-a
* variables:
* debian:
* fn::invoke:
* Function: gcp:compute:getImage
* Arguments:
* family: debian-11
* project: debian-cloud
* ```
*
* ### Snapshot Chainname
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const debian = gcp.compute.getImage({
* family: "debian-11",
* project: "debian-cloud",
* });
* const persistent = new gcp.compute.Disk("persistent", {
* name: "debian-disk",
* image: debian.then(debian => debian.selfLink),
* size: 10,
* type: "pd-ssd",
* zone: "us-central1-a",
* });
* const snapshot = new gcp.compute.Snapshot("snapshot", {
* name: "my-snapshot",
* sourceDisk: persistent.id,
* zone: "us-central1-a",
* chainName: "snapshot-chain",
* labels: {
* my_label: "value",
* },
* storageLocations: ["us-central1"],
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* debian = gcp.compute.get_image(family="debian-11",
* project="debian-cloud")
* persistent = gcp.compute.Disk("persistent",
* name="debian-disk",
* image=debian.self_link,
* size=10,
* type="pd-ssd",
* zone="us-central1-a")
* snapshot = gcp.compute.Snapshot("snapshot",
* name="my-snapshot",
* source_disk=persistent.id,
* zone="us-central1-a",
* chain_name="snapshot-chain",
* labels={
* "my_label": "value",
* },
* storage_locations=["us-central1"])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var debian = Gcp.Compute.GetImage.Invoke(new()
* {
* Family = "debian-11",
* Project = "debian-cloud",
* });
* var persistent = new Gcp.Compute.Disk("persistent", new()
* {
* Name = "debian-disk",
* Image = debian.Apply(getImageResult => getImageResult.SelfLink),
* Size = 10,
* Type = "pd-ssd",
* Zone = "us-central1-a",
* });
* var snapshot = new Gcp.Compute.Snapshot("snapshot", new()
* {
* Name = "my-snapshot",
* SourceDisk = persistent.Id,
* Zone = "us-central1-a",
* ChainName = "snapshot-chain",
* Labels =
* {
* { "my_label", "value" },
* },
* StorageLocations = new[]
* {
* "us-central1",
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* debian, err := compute.LookupImage(ctx, &compute.LookupImageArgs{
* Family: pulumi.StringRef("debian-11"),
* Project: pulumi.StringRef("debian-cloud"),
* }, nil)
* if err != nil {
* return err
* }
* persistent, err := compute.NewDisk(ctx, "persistent", &compute.DiskArgs{
* Name: pulumi.String("debian-disk"),
* Image: pulumi.String(debian.SelfLink),
* Size: pulumi.Int(10),
* Type: pulumi.String("pd-ssd"),
* Zone: pulumi.String("us-central1-a"),
* })
* if err != nil {
* return err
* }
* _, err = compute.NewSnapshot(ctx, "snapshot", &compute.SnapshotArgs{
* Name: pulumi.String("my-snapshot"),
* SourceDisk: persistent.ID(),
* Zone: pulumi.String("us-central1-a"),
* ChainName: pulumi.String("snapshot-chain"),
* Labels: pulumi.StringMap{
* "my_label": pulumi.String("value"),
* },
* StorageLocations: pulumi.StringArray{
* pulumi.String("us-central1"),
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* 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()
* .name("debian-disk")
* .image(debian.applyValue(getImageResult -> getImageResult.selfLink()))
* .size(10)
* .type("pd-ssd")
* .zone("us-central1-a")
* .build());
* var snapshot = new Snapshot("snapshot", SnapshotArgs.builder()
* .name("my-snapshot")
* .sourceDisk(persistent.id())
* .zone("us-central1-a")
* .chainName("snapshot-chain")
* .labels(Map.of("my_label", "value"))
* .storageLocations("us-central1")
* .build());
* }
* }
* ```
* ```yaml
* resources:
* snapshot:
* type: gcp:compute:Snapshot
* properties:
* name: my-snapshot
* sourceDisk: ${persistent.id}
* zone: us-central1-a
* chainName: snapshot-chain
* labels:
* my_label: value
* storageLocations:
* - us-central1
* persistent:
* type: gcp:compute:Disk
* properties:
* name: debian-disk
* image: ${debian.selfLink}
* size: 10
* type: pd-ssd
* zone: us-central1-a
* variables:
* debian:
* fn::invoke:
* Function: gcp:compute:getImage
* Arguments:
* family: debian-11
* project: debian-cloud
* ```
*
* ## Import
* Snapshot can be imported using any of these accepted formats:
* * `projects/{{project}}/global/snapshots/{{name}}`
* * `{{project}}/{{name}}`
* * `{{name}}`
* When using the `pulumi import` command, Snapshot can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:compute/snapshot:Snapshot default projects/{{project}}/global/snapshots/{{name}}
* ```
* ```sh
* $ pulumi import gcp:compute/snapshot:Snapshot default {{project}}/{{name}}
* ```
* ```sh
* $ pulumi import gcp:compute/snapshot:Snapshot default {{name}}
* ```
*/
public class Snapshot internal constructor(
override val javaResource: com.pulumi.gcp.compute.Snapshot,
) : KotlinCustomResource(javaResource, SnapshotMapper) {
/**
* 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.
*/
public val chainName: Output?
get() = javaResource.chainName().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* Creation timestamp in RFC3339 text format.
*/
public val creationTimestamp: Output
get() = javaResource.creationTimestamp().applyValue({ args0 -> args0 })
/**
* An optional description of this resource.
*/
public val description: Output?
get() = javaResource.description().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* Size of the snapshot, specified in GB.
*/
public val diskSizeGb: Output
get() = javaResource.diskSizeGb().applyValue({ args0 -> args0 })
/**
* All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
*/
public val effectiveLabels: Output
© 2015 - 2025 Weber Informatics LLC | Privacy Policy