getSnapshot

To get more information about Snapshot, see:

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
//by name
const snapshot = gcp.compute.getSnapshot({
name: "my-snapshot",
});
// using a filter
const latest_snapshot = gcp.compute.getSnapshot({
filter: "name != my-snapshot",
mostRecent: true,
});
import pulumi
import pulumi_gcp as gcp
#by name
snapshot = gcp.compute.get_snapshot(name="my-snapshot")
# using a filter
latest_snapshot = gcp.compute.get_snapshot(filter="name != my-snapshot",
most_recent=True)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
//by name
var snapshot = Gcp.Compute.GetSnapshot.Invoke(new()
{
Name = "my-snapshot",
});
// using a filter
var latest_snapshot = Gcp.Compute.GetSnapshot.Invoke(new()
{
Filter = "name != my-snapshot",
MostRecent = true,
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// by name
_, err := compute.LookupSnapshot(ctx, &compute.LookupSnapshotArgs{
Name: pulumi.StringRef("my-snapshot"),
}, nil)
if err != nil {
return err
}
// using a filter
_, 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) {
//by name
final var snapshot = ComputeFunctions.getSnapshot(GetSnapshotArgs.builder()
.name("my-snapshot")
.build());
// using a filter
final var latest-snapshot = ComputeFunctions.getSnapshot(GetSnapshotArgs.builder()
.filter("name != my-snapshot")
.mostRecent(true)
.build());
}
}
variables:
#by name
snapshot:
fn::invoke:
function: gcp:compute:getSnapshot
arguments:
name: my-snapshot
# using a filter
latest-snapshot:
fn::invoke:
function: gcp:compute:getSnapshot
arguments:
filter: name != my-snapshot
mostRecent: true

Return

A collection of values returned by getSnapshot.

Parameters

argument

A collection of arguments for invoking getSnapshot.


suspend fun getSnapshot(filter: String? = null, mostRecent: Boolean? = null, name: String? = null, project: String? = null): GetSnapshotResult

/*

Return

A collection of values returned by getSnapshot.

Parameters

filter

A filter to retrieve the compute snapshot. See API filter parameter documentation for reference. If multiple compute snapshot match, either adjust the filter or specify most_recent. One of name or filter must be provided. If you want to use a regular expression, use the eq (equal) or ne (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Example sourceDisk eq '.*(.*/data-disk$).*'. More details for golang Snapshots list call filters here.

mostRecent

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

name

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

project

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

See also


suspend fun getSnapshot(argument: suspend GetSnapshotPlainArgsBuilder.() -> Unit): GetSnapshotResult

Return

A collection of values returned by getSnapshot.

Parameters

argument

Builder for com.pulumi.gcp.compute.kotlin.inputs.GetSnapshotPlainArgs.

See also