digitalocean.getVolumeSnapshot
Explore with Pulumi AI
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
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;
return await Deployment.RunAsync(() =>
{
var snapshot = DigitalOcean.GetVolumeSnapshot.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.LookupVolumeSnapshot(ctx, &digitalocean.LookupVolumeSnapshotArgs{
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.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()
.mostRecent(true)
.nameRegex("^web")
.region("nyc3")
.build());
}
}
import pulumi
import pulumi_digitalocean as digitalocean
snapshot = digitalocean.get_volume_snapshot(most_recent=True,
name_regex="^web",
region="nyc3")
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
const snapshot = digitalocean.getVolumeSnapshot({
mostRecent: true,
nameRegex: "^web",
region: "nyc3",
});
variables:
snapshot:
fn::invoke:
Function: digitalocean:getVolumeSnapshot
Arguments:
mostRecent: true
nameRegex: ^web
region: nyc3
Reuse the data about a volume snapshot to create a new volume based on it
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 = "nyc3",
Size = 100,
SnapshotId = snapshot.Apply(getVolumeSnapshotResult => getVolumeSnapshotResult.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("nyc3"),
Size: pulumi.Int(100),
SnapshotId: *pulumi.String(snapshot.Id),
})
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.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")
.size(100)
.snapshotId(snapshot.applyValue(getVolumeSnapshotResult -> getVolumeSnapshotResult.id()))
.build());
}
}
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="nyc3",
size=100,
snapshot_id=snapshot.id)
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: "nyc3",
size: 100,
snapshotId: snapshot.then(snapshot => snapshot.id),
});
resources:
foobar:
type: digitalocean:Volume
properties:
region: nyc3
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:
- 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 string
The name of the volume snapshot.
- Name
Regex 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 string
The name of the volume snapshot.
- Name
Regex 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 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.
- name
Regex 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 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.
- name
Regex 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.
- most
Recent 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.
- name
Regex 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:
- Created
At string The date and time the volume snapshot was created.
- Id string
The provider-assigned unique ID for this managed resource.
- Min
Disk intSize 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.
- List<string>
A list of the tags associated to the volume snapshot.
- Volume
Id string The ID of the volume from which the volume snapshot originated.
- Most
Recent bool - Name string
- Name
Regex string - Region string
- Created
At string The date and time the volume snapshot was created.
- Id string
The provider-assigned unique ID for this managed resource.
- Min
Disk intSize 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.
- []string
A list of the tags associated to the volume snapshot.
- Volume
Id string The ID of the volume from which the volume snapshot originated.
- Most
Recent bool - Name string
- Name
Regex string - Region string
- created
At String The date and time the volume snapshot was created.
- id String
The provider-assigned unique ID for this managed resource.
- min
Disk IntegerSize 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.
- List<String>
A list of the tags associated to the volume snapshot.
- volume
Id String The ID of the volume from which the volume snapshot originated.
- most
Recent Boolean - name String
- name
Regex String - region String
- created
At string The date and time the volume snapshot was created.
- id string
The provider-assigned unique ID for this managed resource.
- min
Disk numberSize 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.
- string[]
A list of the tags associated to the volume snapshot.
- volume
Id string The ID of the volume from which the volume snapshot originated.
- most
Recent boolean - name string
- name
Regex 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_ intsize 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.
- 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
- created
At String The date and time the volume snapshot was created.
- id String
The provider-assigned unique ID for this managed resource.
- min
Disk NumberSize 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.
- List<String>
A list of the tags associated to the volume snapshot.
- volume
Id String The ID of the volume from which the volume snapshot originated.
- most
Recent Boolean - name String
- name
Regex 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.