digitalocean logo
DigitalOcean v4.19.0, Mar 15 23

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

using System.Collections.Generic;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var web_snapshot = DigitalOcean.GetDropletSnapshot.Invoke(new()
    {
        MostRecent = true,
        NameRegex = "^web",
        Region = "nyc3",
    });

});
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{
			MostRecent: pulumi.BoolRef(true),
			NameRegex:  pulumi.StringRef("^web"),
			Region:     pulumi.StringRef("nyc3"),
		}, 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()
            .mostRecent(true)
            .nameRegex("^web")
            .region("nyc3")
            .build());

    }
}
import pulumi
import pulumi_digitalocean as digitalocean

web_snapshot = digitalocean.get_droplet_snapshot(most_recent=True,
    name_regex="^web",
    region="nyc3")
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const web-snapshot = digitalocean.getDropletSnapshot({
    mostRecent: true,
    nameRegex: "^web",
    region: "nyc3",
});
variables:
  web-snapshot:
    fn::invoke:
      Function: digitalocean:getDropletSnapshot
      Arguments:
        mostRecent: true
        nameRegex: ^web
        region: nyc3

Create image from snapshot

using System.Collections.Generic;
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)),
        Region = "nyc3",
        Size = "s-2vcpu-4gb",
    });

});
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),
			Region: pulumi.String("nyc3"),
			Size:   pulumi.String("s-2vcpu-4gb"),
		})
		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())
            .region("nyc3")
            .size("s-2vcpu-4gb")
            .build());

    }
}
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,
    region="nyc3",
    size="s-2vcpu-4gb")
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),
    region: "nyc3",
    size: "s-2vcpu-4gb",
});
resources:
  from-snapshot:
    type: digitalocean:Droplet
    properties:
      image: ${["web-snapshot"].id}
      region: nyc3
      size: s-2vcpu-4gb
variables:
  web-snapshot:
    fn::invoke:
      Function: digitalocean:getDropletSnapshot
      Arguments:
        nameRegex: ^web
        region: nyc3
        mostRecent: true

Using getDropletSnapshot

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 getDropletSnapshot(args: GetDropletSnapshotArgs, opts?: InvokeOptions): Promise<GetDropletSnapshotResult>
function getDropletSnapshotOutput(args: GetDropletSnapshotOutputArgs, opts?: InvokeOptions): Output<GetDropletSnapshotResult>
def get_droplet_snapshot(most_recent: Optional[bool] = None,
                         name: Optional[str] = None,
                         name_regex: Optional[str] = None,
                         region: Optional[str] = None,
                         opts: Optional[InvokeOptions] = None) -> GetDropletSnapshotResult
def get_droplet_snapshot_output(most_recent: Optional[pulumi.Input[bool]] = None,
                         name: Optional[pulumi.Input[str]] = None,
                         name_regex: Optional[pulumi.Input[str]] = None,
                         region: Optional[pulumi.Input[str]] = None,
                         opts: Optional[InvokeOptions] = None) -> Output[GetDropletSnapshotResult]
func LookupDropletSnapshot(ctx *Context, args *LookupDropletSnapshotArgs, opts ...InvokeOption) (*LookupDropletSnapshotResult, error)
func LookupDropletSnapshotOutput(ctx *Context, args *LookupDropletSnapshotOutputArgs, opts ...InvokeOption) LookupDropletSnapshotResultOutput

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

public static class GetDropletSnapshot 
{
    public static Task<GetDropletSnapshotResult> InvokeAsync(GetDropletSnapshotArgs args, InvokeOptions? opts = null)
    public static Output<GetDropletSnapshotResult> Invoke(GetDropletSnapshotInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetDropletSnapshotResult> getDropletSnapshot(GetDropletSnapshotArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: digitalocean:index/getDropletSnapshot:getDropletSnapshot
  arguments:
    # arguments dictionary

The following arguments are supported:

MostRecent bool

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

Name string

The name of the Droplet snapshot.

NameRegex string

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 string

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

MostRecent bool

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

Name string

The name of the Droplet snapshot.

NameRegex string

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 string

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

mostRecent Boolean

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

name String

The name of the Droplet snapshot.

nameRegex String

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 String

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

mostRecent boolean

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

name string

The name of the Droplet snapshot.

nameRegex string

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 string

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

most_recent bool

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

name str

The name of the Droplet snapshot.

name_regex str

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 str

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

mostRecent Boolean

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

name String

The name of the Droplet snapshot.

nameRegex String

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 String

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

getDropletSnapshot Result

The following output properties are available:

CreatedAt string

The date and time the Droplet snapshot was created.

DropletId string

The ID of the Droplet from which the Droplet snapshot originated.

Id string

The provider-assigned unique ID for this managed resource.

MinDiskSize int

The minimum size in gigabytes required for a Droplet to be created based on this Droplet snapshot.

Regions List<string>

A list of DigitalOcean region "slugs" indicating where the Droplet snapshot is available.

Size double

The billable size of the Droplet snapshot in gigabytes.

MostRecent bool
Name string
NameRegex string
Region string
CreatedAt string

The date and time the Droplet snapshot was created.

DropletId string

The ID of the Droplet from which the Droplet snapshot originated.

Id string

The provider-assigned unique ID for this managed resource.

MinDiskSize int

The minimum size in gigabytes required for a Droplet to be created based on this Droplet snapshot.

Regions []string

A list of DigitalOcean region "slugs" indicating where the Droplet snapshot is available.

Size float64

The billable size of the Droplet snapshot in gigabytes.

MostRecent bool
Name string
NameRegex string
Region string
createdAt String

The date and time the Droplet snapshot was created.

dropletId String

The ID of the Droplet from which the Droplet snapshot originated.

id String

The provider-assigned unique ID for this managed resource.

minDiskSize Integer

The minimum size in gigabytes required for a Droplet to be created based on this Droplet snapshot.

regions List<String>

A list of DigitalOcean region "slugs" indicating where the Droplet snapshot is available.

size Double

The billable size of the Droplet snapshot in gigabytes.

mostRecent Boolean
name String
nameRegex String
region String
createdAt string

The date and time the Droplet snapshot was created.

dropletId string

The ID of the Droplet from which the Droplet snapshot originated.

id string

The provider-assigned unique ID for this managed resource.

minDiskSize number

The minimum size in gigabytes required for a Droplet to be created based on this Droplet snapshot.

regions string[]

A list of DigitalOcean region "slugs" indicating where the Droplet snapshot is available.

size number

The billable size of the Droplet snapshot in gigabytes.

mostRecent boolean
name string
nameRegex string
region string
created_at str

The date and time the Droplet snapshot was created.

droplet_id str

The ID of the Droplet from which the Droplet snapshot originated.

id str

The provider-assigned unique ID for this managed resource.

min_disk_size int

The minimum size in gigabytes required for a Droplet to be created based on this Droplet snapshot.

regions Sequence[str]

A list of DigitalOcean region "slugs" indicating where the Droplet snapshot is available.

size float

The billable size of the Droplet snapshot in gigabytes.

most_recent bool
name str
name_regex str
region str
createdAt String

The date and time the Droplet snapshot was created.

dropletId String

The ID of the Droplet from which the Droplet snapshot originated.

id String

The provider-assigned unique ID for this managed resource.

minDiskSize Number

The minimum size in gigabytes required for a Droplet to be created based on this Droplet snapshot.

regions List<String>

A list of DigitalOcean region "slugs" indicating where the Droplet snapshot is available.

size Number

The billable size of the Droplet snapshot in gigabytes.

mostRecent Boolean
name String
nameRegex String
region String

Package Details

Repository
DigitalOcean pulumi/pulumi-digitalocean
License
Apache-2.0
Notes

This Pulumi package is based on the digitalocean Terraform Provider.