1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. getSnapshot
Google Cloud Classic v7.2.1 published on Wednesday, Nov 22, 2023 by Pulumi

gcp.compute.getSnapshot

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.2.1 published on Wednesday, Nov 22, 2023 by Pulumi

    To get more information about Snapshot, see:

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var snapshot = Gcp.Compute.GetSnapshot.Invoke(new()
        {
            Name = "my-snapshot",
        });
    
        var latest_snapshot = Gcp.Compute.GetSnapshot.Invoke(new()
        {
            Filter = "name != my-snapshot",
            MostRecent = true,
        });
    
    });
    
    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 {
    		_, err := compute.LookupSnapshot(ctx, &compute.LookupSnapshotArgs{
    			Name: pulumi.StringRef("my-snapshot"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = compute.LookupSnapshot(ctx, &compute.LookupSnapshotArgs{
    			Filter:     pulumi.StringRef("name != my-snapshot"),
    			MostRecent: pulumi.BoolRef(true),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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.GetSnapshotArgs;
    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 snapshot = ComputeFunctions.getSnapshot(GetSnapshotArgs.builder()
                .name("my-snapshot")
                .build());
    
            final var latest-snapshot = ComputeFunctions.getSnapshot(GetSnapshotArgs.builder()
                .filter("name != my-snapshot")
                .mostRecent(true)
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_gcp as gcp
    
    snapshot = gcp.compute.get_snapshot(name="my-snapshot")
    latest_snapshot = gcp.compute.get_snapshot(filter="name != my-snapshot",
        most_recent=True)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const snapshot = gcp.compute.getSnapshot({
        name: "my-snapshot",
    });
    const latest-snapshot = gcp.compute.getSnapshot({
        filter: "name != my-snapshot",
        mostRecent: true,
    });
    
    variables:
      snapshot:
        fn::invoke:
          Function: gcp:compute:getSnapshot
          Arguments:
            name: my-snapshot
      latest-snapshot:
        fn::invoke:
          Function: gcp:compute:getSnapshot
          Arguments:
            filter: name != my-snapshot
            mostRecent: true
    

    Using getSnapshot

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getSnapshot(args: GetSnapshotArgs, opts?: InvokeOptions): Promise<GetSnapshotResult>
    function getSnapshotOutput(args: GetSnapshotOutputArgs, opts?: InvokeOptions): Output<GetSnapshotResult>
    def get_snapshot(filter: Optional[str] = None,
                     most_recent: Optional[bool] = None,
                     name: Optional[str] = None,
                     project: Optional[str] = None,
                     opts: Optional[InvokeOptions] = None) -> GetSnapshotResult
    def get_snapshot_output(filter: Optional[pulumi.Input[str]] = None,
                     most_recent: Optional[pulumi.Input[bool]] = None,
                     name: Optional[pulumi.Input[str]] = None,
                     project: Optional[pulumi.Input[str]] = None,
                     opts: Optional[InvokeOptions] = None) -> Output[GetSnapshotResult]
    func LookupSnapshot(ctx *Context, args *LookupSnapshotArgs, opts ...InvokeOption) (*LookupSnapshotResult, error)
    func LookupSnapshotOutput(ctx *Context, args *LookupSnapshotOutputArgs, opts ...InvokeOption) LookupSnapshotResultOutput

    > Note: This function is named LookupSnapshot in the Go SDK.

    public static class GetSnapshot 
    {
        public static Task<GetSnapshotResult> InvokeAsync(GetSnapshotArgs args, InvokeOptions? opts = null)
        public static Output<GetSnapshotResult> Invoke(GetSnapshotInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetSnapshotResult> getSnapshot(GetSnapshotArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: gcp:compute/getSnapshot:getSnapshot
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Filter string

    A filter to retrieve the compute snapshot. See gcloud topic filters for reference. If multiple compute snapshot match, either adjust the filter or specify most_recent. One of name or filter must be provided.

    MostRecent bool

    If filter is provided, ensures the most recent snapshot is returned when multiple compute snapshot match.


    Name string

    The name of the compute snapshot. One of name or filter must be provided.

    Project string

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

    Filter string

    A filter to retrieve the compute snapshot. See gcloud topic filters for reference. If multiple compute snapshot match, either adjust the filter or specify most_recent. One of name or filter must be provided.

    MostRecent bool

    If filter is provided, ensures the most recent snapshot is returned when multiple compute snapshot match.


    Name string

    The name of the compute snapshot. One of name or filter must be provided.

    Project string

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

    filter String

    A filter to retrieve the compute snapshot. See gcloud topic filters for reference. If multiple compute snapshot match, either adjust the filter or specify most_recent. One of name or filter must be provided.

    mostRecent Boolean

    If filter is provided, ensures the most recent snapshot is returned when multiple compute snapshot match.


    name String

    The name of the compute snapshot. One of name or filter must be provided.

    project String

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

    filter string

    A filter to retrieve the compute snapshot. See gcloud topic filters for reference. If multiple compute snapshot match, either adjust the filter or specify most_recent. One of name or filter must be provided.

    mostRecent boolean

    If filter is provided, ensures the most recent snapshot is returned when multiple compute snapshot match.


    name string

    The name of the compute snapshot. One of name or filter must be provided.

    project string

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

    filter str

    A filter to retrieve the compute snapshot. See gcloud topic filters for reference. If multiple compute snapshot match, either adjust the filter or specify most_recent. One of name or filter must be provided.

    most_recent bool

    If filter is provided, ensures the most recent snapshot is returned when multiple compute snapshot match.


    name str

    The name of the compute snapshot. One of name or filter must be provided.

    project str

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

    filter String

    A filter to retrieve the compute snapshot. See gcloud topic filters for reference. If multiple compute snapshot match, either adjust the filter or specify most_recent. One of name or filter must be provided.

    mostRecent Boolean

    If filter is provided, ensures the most recent snapshot is returned when multiple compute snapshot match.


    name String

    The name of the compute snapshot. One of name or filter must be provided.

    project String

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

    getSnapshot Result

    The following output properties are available:

    ChainName string
    CreationTimestamp string
    Description string
    DiskSizeGb int
    EffectiveLabels Dictionary<string, string>
    Id string

    The provider-assigned unique ID for this managed resource.

    LabelFingerprint string
    Labels Dictionary<string, string>
    Licenses List<string>
    PulumiLabels Dictionary<string, string>
    SelfLink string
    SnapshotEncryptionKeys List<GetSnapshotSnapshotEncryptionKey>
    SnapshotId int
    SourceDisk string
    SourceDiskEncryptionKeys List<GetSnapshotSourceDiskEncryptionKey>
    StorageBytes int
    StorageLocations List<string>
    Zone string
    Filter string
    MostRecent bool
    Name string
    Project string
    ChainName string
    CreationTimestamp string
    Description string
    DiskSizeGb int
    EffectiveLabels map[string]string
    Id string

    The provider-assigned unique ID for this managed resource.

    LabelFingerprint string
    Labels map[string]string
    Licenses []string
    PulumiLabels map[string]string
    SelfLink string
    SnapshotEncryptionKeys []GetSnapshotSnapshotEncryptionKey
    SnapshotId int
    SourceDisk string
    SourceDiskEncryptionKeys []GetSnapshotSourceDiskEncryptionKey
    StorageBytes int
    StorageLocations []string
    Zone string
    Filter string
    MostRecent bool
    Name string
    Project string
    chainName String
    creationTimestamp String
    description String
    diskSizeGb Integer
    effectiveLabels Map<String,String>
    id String

    The provider-assigned unique ID for this managed resource.

    labelFingerprint String
    labels Map<String,String>
    licenses List<String>
    pulumiLabels Map<String,String>
    selfLink String
    snapshotEncryptionKeys List<GetSnapshotSnapshotEncryptionKey>
    snapshotId Integer
    sourceDisk String
    sourceDiskEncryptionKeys List<GetSnapshotSourceDiskEncryptionKey>
    storageBytes Integer
    storageLocations List<String>
    zone String
    filter String
    mostRecent Boolean
    name String
    project String
    chainName string
    creationTimestamp string
    description string
    diskSizeGb number
    effectiveLabels {[key: string]: string}
    id string

    The provider-assigned unique ID for this managed resource.

    labelFingerprint string
    labels {[key: string]: string}
    licenses string[]
    pulumiLabels {[key: string]: string}
    selfLink string
    snapshotEncryptionKeys GetSnapshotSnapshotEncryptionKey[]
    snapshotId number
    sourceDisk string
    sourceDiskEncryptionKeys GetSnapshotSourceDiskEncryptionKey[]
    storageBytes number
    storageLocations string[]
    zone string
    filter string
    mostRecent boolean
    name string
    project string
    chainName String
    creationTimestamp String
    description String
    diskSizeGb Number
    effectiveLabels Map<String>
    id String

    The provider-assigned unique ID for this managed resource.

    labelFingerprint String
    labels Map<String>
    licenses List<String>
    pulumiLabels Map<String>
    selfLink String
    snapshotEncryptionKeys List<Property Map>
    snapshotId Number
    sourceDisk String
    sourceDiskEncryptionKeys List<Property Map>
    storageBytes Number
    storageLocations List<String>
    zone String
    filter String
    mostRecent Boolean
    name String
    project String

    Supporting Types

    GetSnapshotSnapshotEncryptionKey

    GetSnapshotSourceDiskEncryptionKey

    Package Details

    Repository
    Google Cloud (GCP) Classic pulumi/pulumi-gcp
    License
    Apache-2.0
    Notes

    This Pulumi package is based on the google-beta Terraform Provider.

    gcp logo
    Google Cloud Classic v7.2.1 published on Wednesday, Nov 22, 2023 by Pulumi