1. Packages
  2. Digitalocean Provider
  3. API Docs
  4. getVolumeSnapshot
DigitalOcean v4.33.0 published on Thursday, Sep 26, 2024 by Pulumi

digitalocean.getVolumeSnapshot

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.33.0 published on Thursday, Sep 26, 2024 by Pulumi

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

    Example Usage

    Get the volume snapshot:

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const snapshot = digitalocean.getVolumeSnapshot({
        nameRegex: "^web",
        region: "nyc3",
        mostRecent: true,
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    snapshot = digitalocean.get_volume_snapshot(name_regex="^web",
        region="nyc3",
        most_recent=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.LookupVolumeSnapshot(ctx, &digitalocean.LookupVolumeSnapshotArgs{
    			NameRegex:  pulumi.StringRef("^web"),
    			Region:     pulumi.StringRef("nyc3"),
    			MostRecent: pulumi.BoolRef(true),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using DigitalOcean = Pulumi.DigitalOcean;
    
    return await Deployment.RunAsync(() => 
    {
        var snapshot = DigitalOcean.GetVolumeSnapshot.Invoke(new()
        {
            NameRegex = "^web",
            Region = "nyc3",
            MostRecent = true,
        });
    
    });
    
    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.GetVolumeSnapshotArgs;
    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 = DigitaloceanFunctions.getVolumeSnapshot(GetVolumeSnapshotArgs.builder()
                .nameRegex("^web")
                .region("nyc3")
                .mostRecent(true)
                .build());
    
        }
    }
    
    variables:
      snapshot:
        fn::invoke:
          Function: digitalocean:getVolumeSnapshot
          Arguments:
            nameRegex: ^web
            region: nyc3
            mostRecent: true
    

    Reuse the data about a volume snapshot to create a new volume based on it:

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const snapshot = digitalocean.getVolumeSnapshot({
        nameRegex: "^web",
        region: "nyc3",
        mostRecent: true,
    });
    const foobar = new digitalocean.Volume("foobar", {
        region: digitalocean.Region.NYC3,
        name: "baz",
        size: 100,
        snapshotId: snapshot.then(snapshot => snapshot.id),
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    snapshot = digitalocean.get_volume_snapshot(name_regex="^web",
        region="nyc3",
        most_recent=True)
    foobar = digitalocean.Volume("foobar",
        region=digitalocean.Region.NYC3,
        name="baz",
        size=100,
        snapshot_id=snapshot.id)
    
    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 {
    		snapshot, err := digitalocean.LookupVolumeSnapshot(ctx, &digitalocean.LookupVolumeSnapshotArgs{
    			NameRegex:  pulumi.StringRef("^web"),
    			Region:     pulumi.StringRef("nyc3"),
    			MostRecent: pulumi.BoolRef(true),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = digitalocean.NewVolume(ctx, "foobar", &digitalocean.VolumeArgs{
    			Region:     pulumi.String(digitalocean.RegionNYC3),
    			Name:       pulumi.String("baz"),
    			Size:       pulumi.Int(100),
    			SnapshotId: pulumi.String(snapshot.Id),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using DigitalOcean = Pulumi.DigitalOcean;
    
    return await Deployment.RunAsync(() => 
    {
        var snapshot = DigitalOcean.GetVolumeSnapshot.Invoke(new()
        {
            NameRegex = "^web",
            Region = "nyc3",
            MostRecent = true,
        });
    
        var foobar = new DigitalOcean.Volume("foobar", new()
        {
            Region = DigitalOcean.Region.NYC3,
            Name = "baz",
            Size = 100,
            SnapshotId = snapshot.Apply(getVolumeSnapshotResult => getVolumeSnapshotResult.Id),
        });
    
    });
    
    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.GetVolumeSnapshotArgs;
    import com.pulumi.digitalocean.Volume;
    import com.pulumi.digitalocean.VolumeArgs;
    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 = DigitaloceanFunctions.getVolumeSnapshot(GetVolumeSnapshotArgs.builder()
                .nameRegex("^web")
                .region("nyc3")
                .mostRecent(true)
                .build());
    
            var foobar = new Volume("foobar", VolumeArgs.builder()
                .region("nyc3")
                .name("baz")
                .size(100)
                .snapshotId(snapshot.applyValue(getVolumeSnapshotResult -> getVolumeSnapshotResult.id()))
                .build());
    
        }
    }
    
    resources:
      foobar:
        type: digitalocean:Volume
        properties:
          region: nyc3
          name: baz
          size: 100
          snapshotId: ${snapshot.id}
    variables:
      snapshot:
        fn::invoke:
          Function: digitalocean:getVolumeSnapshot
          Arguments:
            nameRegex: ^web
            region: nyc3
            mostRecent: true
    

    Using getVolumeSnapshot

    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 getVolumeSnapshot(args: GetVolumeSnapshotArgs, opts?: InvokeOptions): Promise<GetVolumeSnapshotResult>
    function getVolumeSnapshotOutput(args: GetVolumeSnapshotOutputArgs, opts?: InvokeOptions): Output<GetVolumeSnapshotResult>
    def get_volume_snapshot(most_recent: Optional[bool] = None,
                            name: Optional[str] = None,
                            name_regex: Optional[str] = None,
                            region: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetVolumeSnapshotResult
    def get_volume_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[GetVolumeSnapshotResult]
    func LookupVolumeSnapshot(ctx *Context, args *LookupVolumeSnapshotArgs, opts ...InvokeOption) (*LookupVolumeSnapshotResult, error)
    func LookupVolumeSnapshotOutput(ctx *Context, args *LookupVolumeSnapshotOutputArgs, opts ...InvokeOption) LookupVolumeSnapshotResultOutput

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

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

    The following arguments are supported:

    MostRecent bool

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

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

    Name string
    The name of the volume snapshot.
    NameRegex string
    A regex string to apply to the volume 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 volume snapshots available in the region will be returned.
    MostRecent bool

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

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

    Name string
    The name of the volume snapshot.
    NameRegex string
    A regex string to apply to the volume 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 volume snapshots available in the region will be returned.
    mostRecent Boolean

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

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

    name String
    The name of the volume snapshot.
    nameRegex String
    A regex string to apply to the volume 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 volume snapshots available in the region will be returned.
    mostRecent boolean

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

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

    name string
    The name of the volume snapshot.
    nameRegex string
    A regex string to apply to the volume 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 volume snapshots available in the region will be returned.
    most_recent bool

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

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

    name str
    The name of the volume snapshot.
    name_regex str
    A regex string to apply to the volume 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 volume snapshots available in the region will be returned.
    mostRecent Boolean

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

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

    name String
    The name of the volume snapshot.
    nameRegex String
    A regex string to apply to the volume 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 volume snapshots available in the region will be returned.

    getVolumeSnapshot Result

    The following output properties are available:

    CreatedAt string
    The date and time the volume snapshot was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    MinDiskSize int
    The minimum size in gigabytes required for a volume to be created based on this volume snapshot.
    Regions List<string>
    A list of DigitalOcean region "slugs" indicating where the volume snapshot is available.
    Size double
    The billable size of the volume snapshot in gigabytes.
    Tags List<string>
    A list of the tags associated to the volume snapshot.
    VolumeId string
    The ID of the volume from which the volume snapshot originated.
    MostRecent bool
    Name string
    NameRegex string
    Region string
    CreatedAt string
    The date and time the volume snapshot was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    MinDiskSize int
    The minimum size in gigabytes required for a volume to be created based on this volume snapshot.
    Regions []string
    A list of DigitalOcean region "slugs" indicating where the volume snapshot is available.
    Size float64
    The billable size of the volume snapshot in gigabytes.
    Tags []string
    A list of the tags associated to the volume snapshot.
    VolumeId string
    The ID of the volume from which the volume snapshot originated.
    MostRecent bool
    Name string
    NameRegex string
    Region string
    createdAt String
    The date and time the volume snapshot was created.
    id String
    The provider-assigned unique ID for this managed resource.
    minDiskSize Integer
    The minimum size in gigabytes required for a volume to be created based on this volume snapshot.
    regions List<String>
    A list of DigitalOcean region "slugs" indicating where the volume snapshot is available.
    size Double
    The billable size of the volume snapshot in gigabytes.
    tags List<String>
    A list of the tags associated to the volume snapshot.
    volumeId String
    The ID of the volume from which the volume snapshot originated.
    mostRecent Boolean
    name String
    nameRegex String
    region String
    createdAt string
    The date and time the volume snapshot was created.
    id string
    The provider-assigned unique ID for this managed resource.
    minDiskSize number
    The minimum size in gigabytes required for a volume to be created based on this volume snapshot.
    regions string[]
    A list of DigitalOcean region "slugs" indicating where the volume snapshot is available.
    size number
    The billable size of the volume snapshot in gigabytes.
    tags string[]
    A list of the tags associated to the volume snapshot.
    volumeId string
    The ID of the volume from which the volume snapshot originated.
    mostRecent boolean
    name string
    nameRegex string
    region string
    created_at str
    The date and time the volume snapshot was created.
    id str
    The provider-assigned unique ID for this managed resource.
    min_disk_size int
    The minimum size in gigabytes required for a volume to be created based on this volume snapshot.
    regions Sequence[str]
    A list of DigitalOcean region "slugs" indicating where the volume snapshot is available.
    size float
    The billable size of the volume snapshot in gigabytes.
    tags Sequence[str]
    A list of the tags associated to the volume snapshot.
    volume_id str
    The ID of the volume from which the volume snapshot originated.
    most_recent bool
    name str
    name_regex str
    region str
    createdAt String
    The date and time the volume snapshot was created.
    id String
    The provider-assigned unique ID for this managed resource.
    minDiskSize Number
    The minimum size in gigabytes required for a volume to be created based on this volume snapshot.
    regions List<String>
    A list of DigitalOcean region "slugs" indicating where the volume snapshot is available.
    size Number
    The billable size of the volume snapshot in gigabytes.
    tags List<String>
    A list of the tags associated to the volume snapshot.
    volumeId String
    The ID of the volume from which the volume snapshot originated.
    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.
    digitalocean logo
    DigitalOcean v4.33.0 published on Thursday, Sep 26, 2024 by Pulumi