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

digitalocean.getVolume

Explore with Pulumi AI

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

    Get information on a volume for use in other resources. This data source provides all of the volumes properties as configured on your DigitalOcean account. This is useful if the volume in question is not managed by the provider or you need to utilize any of the volumes data.

    An error is triggered if the provided volume name does not exist.

    Example Usage

    Get the volume:

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const example = digitalocean.getVolume({
        name: "app-data",
        region: "nyc3",
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    example = digitalocean.get_volume(name="app-data",
        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.LookupVolume(ctx, &digitalocean.LookupVolumeArgs{
    			Name:   "app-data",
    			Region: pulumi.StringRef("nyc3"),
    		}, 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 example = DigitalOcean.GetVolume.Invoke(new()
        {
            Name = "app-data",
            Region = "nyc3",
        });
    
    });
    
    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.GetVolumeArgs;
    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 example = DigitaloceanFunctions.getVolume(GetVolumeArgs.builder()
                .name("app-data")
                .region("nyc3")
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          Function: digitalocean:getVolume
          Arguments:
            name: app-data
            region: nyc3
    

    Reuse the data about a volume to attach it to a Droplet:

    import * as pulumi from "@pulumi/pulumi";
    import * as digitalocean from "@pulumi/digitalocean";
    
    const example = digitalocean.getVolume({
        name: "app-data",
        region: "nyc3",
    });
    const exampleDroplet = new digitalocean.Droplet("example", {
        name: "foo",
        size: digitalocean.DropletSlug.DropletS1VCPU1GB,
        image: "ubuntu-18-04-x64",
        region: digitalocean.Region.NYC3,
    });
    const foobar = new digitalocean.VolumeAttachment("foobar", {
        dropletId: exampleDroplet.id,
        volumeId: example.then(example => example.id),
    });
    
    import pulumi
    import pulumi_digitalocean as digitalocean
    
    example = digitalocean.get_volume(name="app-data",
        region="nyc3")
    example_droplet = digitalocean.Droplet("example",
        name="foo",
        size=digitalocean.DropletSlug.DROPLET_S1_VCPU1_GB,
        image="ubuntu-18-04-x64",
        region=digitalocean.Region.NYC3)
    foobar = digitalocean.VolumeAttachment("foobar",
        droplet_id=example_droplet.id,
        volume_id=example.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 {
    		example, err := digitalocean.LookupVolume(ctx, &digitalocean.LookupVolumeArgs{
    			Name:   "app-data",
    			Region: pulumi.StringRef("nyc3"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		exampleDroplet, err := digitalocean.NewDroplet(ctx, "example", &digitalocean.DropletArgs{
    			Name:   pulumi.String("foo"),
    			Size:   pulumi.String(digitalocean.DropletSlugDropletS1VCPU1GB),
    			Image:  pulumi.String("ubuntu-18-04-x64"),
    			Region: pulumi.String(digitalocean.RegionNYC3),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = digitalocean.NewVolumeAttachment(ctx, "foobar", &digitalocean.VolumeAttachmentArgs{
    			DropletId: exampleDroplet.ID(),
    			VolumeId:  pulumi.String(example.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 example = DigitalOcean.GetVolume.Invoke(new()
        {
            Name = "app-data",
            Region = "nyc3",
        });
    
        var exampleDroplet = new DigitalOcean.Droplet("example", new()
        {
            Name = "foo",
            Size = DigitalOcean.DropletSlug.DropletS1VCPU1GB,
            Image = "ubuntu-18-04-x64",
            Region = DigitalOcean.Region.NYC3,
        });
    
        var foobar = new DigitalOcean.VolumeAttachment("foobar", new()
        {
            DropletId = exampleDroplet.Id,
            VolumeId = example.Apply(getVolumeResult => getVolumeResult.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.GetVolumeArgs;
    import com.pulumi.digitalocean.Droplet;
    import com.pulumi.digitalocean.DropletArgs;
    import com.pulumi.digitalocean.VolumeAttachment;
    import com.pulumi.digitalocean.VolumeAttachmentArgs;
    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 example = DigitaloceanFunctions.getVolume(GetVolumeArgs.builder()
                .name("app-data")
                .region("nyc3")
                .build());
    
            var exampleDroplet = new Droplet("exampleDroplet", DropletArgs.builder()
                .name("foo")
                .size("s-1vcpu-1gb")
                .image("ubuntu-18-04-x64")
                .region("nyc3")
                .build());
    
            var foobar = new VolumeAttachment("foobar", VolumeAttachmentArgs.builder()
                .dropletId(exampleDroplet.id())
                .volumeId(example.applyValue(getVolumeResult -> getVolumeResult.id()))
                .build());
    
        }
    }
    
    resources:
      exampleDroplet:
        type: digitalocean:Droplet
        name: example
        properties:
          name: foo
          size: s-1vcpu-1gb
          image: ubuntu-18-04-x64
          region: nyc3
      foobar:
        type: digitalocean:VolumeAttachment
        properties:
          dropletId: ${exampleDroplet.id}
          volumeId: ${example.id}
    variables:
      example:
        fn::invoke:
          Function: digitalocean:getVolume
          Arguments:
            name: app-data
            region: nyc3
    

    Using getVolume

    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 getVolume(args: GetVolumeArgs, opts?: InvokeOptions): Promise<GetVolumeResult>
    function getVolumeOutput(args: GetVolumeOutputArgs, opts?: InvokeOptions): Output<GetVolumeResult>
    def get_volume(description: Optional[str] = None,
                   name: Optional[str] = None,
                   region: Optional[str] = None,
                   opts: Optional[InvokeOptions] = None) -> GetVolumeResult
    def get_volume_output(description: Optional[pulumi.Input[str]] = None,
                   name: Optional[pulumi.Input[str]] = None,
                   region: Optional[pulumi.Input[str]] = None,
                   opts: Optional[InvokeOptions] = None) -> Output[GetVolumeResult]
    func LookupVolume(ctx *Context, args *LookupVolumeArgs, opts ...InvokeOption) (*LookupVolumeResult, error)
    func LookupVolumeOutput(ctx *Context, args *LookupVolumeOutputArgs, opts ...InvokeOption) LookupVolumeResultOutput

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

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

    The following arguments are supported:

    Name string
    The name of block storage volume.
    Description string
    Text describing a block storage volume.
    Region string
    The region the block storage volume is provisioned in.
    Name string
    The name of block storage volume.
    Description string
    Text describing a block storage volume.
    Region string
    The region the block storage volume is provisioned in.
    name String
    The name of block storage volume.
    description String
    Text describing a block storage volume.
    region String
    The region the block storage volume is provisioned in.
    name string
    The name of block storage volume.
    description string
    Text describing a block storage volume.
    region string
    The region the block storage volume is provisioned in.
    name str
    The name of block storage volume.
    description str
    Text describing a block storage volume.
    region str
    The region the block storage volume is provisioned in.
    name String
    The name of block storage volume.
    description String
    Text describing a block storage volume.
    region String
    The region the block storage volume is provisioned in.

    getVolume Result

    The following output properties are available:

    DropletIds List<int>
    A list of associated Droplet ids.
    FilesystemLabel string
    Filesystem label currently in-use on the block storage volume.
    FilesystemType string
    Filesystem type currently in-use on the block storage volume.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    Size int
    The size of the block storage volume in GiB.
    Tags List<string>
    A list of the tags associated to the Volume.
    Urn string
    The uniform resource name for the storage volume.
    Description string
    Text describing a block storage volume.
    Region string
    DropletIds []int
    A list of associated Droplet ids.
    FilesystemLabel string
    Filesystem label currently in-use on the block storage volume.
    FilesystemType string
    Filesystem type currently in-use on the block storage volume.
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    Size int
    The size of the block storage volume in GiB.
    Tags []string
    A list of the tags associated to the Volume.
    Urn string
    The uniform resource name for the storage volume.
    Description string
    Text describing a block storage volume.
    Region string
    dropletIds List<Integer>
    A list of associated Droplet ids.
    filesystemLabel String
    Filesystem label currently in-use on the block storage volume.
    filesystemType String
    Filesystem type currently in-use on the block storage volume.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    size Integer
    The size of the block storage volume in GiB.
    tags List<String>
    A list of the tags associated to the Volume.
    urn String
    The uniform resource name for the storage volume.
    description String
    Text describing a block storage volume.
    region String
    dropletIds number[]
    A list of associated Droplet ids.
    filesystemLabel string
    Filesystem label currently in-use on the block storage volume.
    filesystemType string
    Filesystem type currently in-use on the block storage volume.
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    size number
    The size of the block storage volume in GiB.
    tags string[]
    A list of the tags associated to the Volume.
    urn string
    The uniform resource name for the storage volume.
    description string
    Text describing a block storage volume.
    region string
    droplet_ids Sequence[int]
    A list of associated Droplet ids.
    filesystem_label str
    Filesystem label currently in-use on the block storage volume.
    filesystem_type str
    Filesystem type currently in-use on the block storage volume.
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    size int
    The size of the block storage volume in GiB.
    tags Sequence[str]
    A list of the tags associated to the Volume.
    urn str
    The uniform resource name for the storage volume.
    description str
    Text describing a block storage volume.
    region str
    dropletIds List<Number>
    A list of associated Droplet ids.
    filesystemLabel String
    Filesystem label currently in-use on the block storage volume.
    filesystemType String
    Filesystem type currently in-use on the block storage volume.
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    size Number
    The size of the block storage volume in GiB.
    tags List<String>
    A list of the tags associated to the Volume.
    urn String
    The uniform resource name for the storage volume.
    description String
    Text describing a block storage volume.
    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