getDropletSnapshot

Droplet snapshots are saved instances of a Droplet. Use this data source to retrieve the ID of a DigitalOcean Droplet snapshot for use in other resources.

Example Usage

Get the Droplet snapshot:

import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
const web_snapshot = digitalocean.getDropletSnapshot({
nameRegex: "^web",
region: "nyc3",
mostRecent: true,
});
import pulumi
import pulumi_digitalocean as digitalocean
web_snapshot = digitalocean.get_droplet_snapshot(name_regex="^web",
region="nyc3",
most_recent=True)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;
return await Deployment.RunAsync(() =>
{
var web_snapshot = DigitalOcean.GetDropletSnapshot.Invoke(new()
{
NameRegex = "^web",
Region = "nyc3",
MostRecent = true,
});
});
package main
import (
"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := digitalocean.LookupDropletSnapshot(ctx, &digitalocean.LookupDropletSnapshotArgs{
NameRegex: pulumi.StringRef("^web"),
Region: pulumi.StringRef("nyc3"),
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.digitalocean.DigitaloceanFunctions;
import com.pulumi.digitalocean.inputs.GetDropletSnapshotArgs;
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 web-snapshot = DigitaloceanFunctions.getDropletSnapshot(GetDropletSnapshotArgs.builder()
.nameRegex("^web")
.region("nyc3")
.mostRecent(true)
.build());
}
}
variables:
web-snapshot:
fn::invoke:
function: digitalocean:getDropletSnapshot
arguments:
nameRegex: ^web
region: nyc3
mostRecent: true

Create image from snapshot:

import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
const web_snapshot = digitalocean.getDropletSnapshot({
nameRegex: "^web",
region: "nyc3",
mostRecent: true,
});
const from_snapshot = new digitalocean.Droplet("from-snapshot", {
image: web_snapshot.then(web_snapshot => web_snapshot.id),
name: "web-02",
region: digitalocean.Region.NYC3,
size: digitalocean.DropletSlug.DropletS2VCPU4GB,
});
import pulumi
import pulumi_digitalocean as digitalocean
web_snapshot = digitalocean.get_droplet_snapshot(name_regex="^web",
region="nyc3",
most_recent=True)
from_snapshot = digitalocean.Droplet("from-snapshot",
image=web_snapshot.id,
name="web-02",
region=digitalocean.Region.NYC3,
size=digitalocean.DropletSlug.DROPLET_S2_VCPU4_GB)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;
return await Deployment.RunAsync(() =>
{
var web_snapshot = DigitalOcean.GetDropletSnapshot.Invoke(new()
{
NameRegex = "^web",
Region = "nyc3",
MostRecent = true,
});
var from_snapshot = new DigitalOcean.Droplet("from-snapshot", new()
{
Image = web_snapshot.Apply(web_snapshot => web_snapshot.Apply(getDropletSnapshotResult => getDropletSnapshotResult.Id)),
Name = "web-02",
Region = DigitalOcean.Region.NYC3,
Size = DigitalOcean.DropletSlug.DropletS2VCPU4GB,
});
});
package main
import (
"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
web_snapshot, err := digitalocean.LookupDropletSnapshot(ctx, &digitalocean.LookupDropletSnapshotArgs{
NameRegex: pulumi.StringRef("^web"),
Region: pulumi.StringRef("nyc3"),
MostRecent: pulumi.BoolRef(true),
}, nil)
if err != nil {
return err
}
_, err = digitalocean.NewDroplet(ctx, "from-snapshot", &digitalocean.DropletArgs{
Image: pulumi.String(web_snapshot.Id),
Name: pulumi.String("web-02"),
Region: pulumi.String(digitalocean.RegionNYC3),
Size: pulumi.String(digitalocean.DropletSlugDropletS2VCPU4GB),
})
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.digitalocean.DigitaloceanFunctions;
import com.pulumi.digitalocean.inputs.GetDropletSnapshotArgs;
import com.pulumi.digitalocean.Droplet;
import com.pulumi.digitalocean.DropletArgs;
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 web-snapshot = DigitaloceanFunctions.getDropletSnapshot(GetDropletSnapshotArgs.builder()
.nameRegex("^web")
.region("nyc3")
.mostRecent(true)
.build());
var from_snapshot = new Droplet("from-snapshot", DropletArgs.builder()
.image(web_snapshot.id())
.name("web-02")
.region("nyc3")
.size("s-2vcpu-4gb")
.build());
}
}
resources:
from-snapshot:
type: digitalocean:Droplet
properties:
image: ${["web-snapshot"].id}
name: web-02
region: nyc3
size: s-2vcpu-4gb
variables:
web-snapshot:
fn::invoke:
function: digitalocean:getDropletSnapshot
arguments:
nameRegex: ^web
region: nyc3
mostRecent: true

Return

A collection of values returned by getDropletSnapshot.

Parameters

argument

A collection of arguments for invoking getDropletSnapshot.


suspend fun getDropletSnapshot(mostRecent: Boolean? = null, name: String? = null, nameRegex: String? = null, region: String? = null): GetDropletSnapshotResult

Return

A collection of values returned by getDropletSnapshot.

Parameters

mostRecent

If more than one result is returned, use the most recent Droplet snapshot.

NOTE: If more or less than a single match is returned by the search, the update will fail. Ensure that your search is specific enough to return a single Droplet snapshot ID only, or use most_recent to choose the most recent one.

name

The name of the Droplet snapshot.

nameRegex

A regex string to apply to the Droplet snapshot list returned by DigitalOcean. This allows more advanced filtering not supported from the DigitalOcean API. This filtering is done locally on what DigitalOcean returns.

region

A "slug" representing a DigitalOcean region (e.g. nyc1). If set, only Droplet snapshots available in the region will be returned.

See also


Return

A collection of values returned by getDropletSnapshot.

Parameters

argument

Builder for com.pulumi.digitalocean.kotlin.inputs.GetDropletSnapshotPlainArgs.

See also