1. Packages
  2. Hcloud Provider
  3. API Docs
  4. getVolume
Hetzner Cloud v1.21.0 published on Tuesday, Nov 12, 2024 by Pulumi

hcloud.getVolume

Explore with Pulumi AI

hcloud logo
Hetzner Cloud v1.21.0 published on Tuesday, Nov 12, 2024 by Pulumi

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as hcloud from "@pulumi/hcloud";
    
    const volume1 = hcloud.getVolume({
        id: 1234,
    });
    const volume2 = hcloud.getVolume({
        name: "my-volume",
    });
    const volume3 = hcloud.getVolume({
        withSelector: "key=value",
    });
    
    import pulumi
    import pulumi_hcloud as hcloud
    
    volume1 = hcloud.get_volume(id=1234)
    volume2 = hcloud.get_volume(name="my-volume")
    volume3 = hcloud.get_volume(with_selector="key=value")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-hcloud/sdk/go/hcloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := hcloud.LookupVolume(ctx, &hcloud.LookupVolumeArgs{
    			Id: pulumi.IntRef(1234),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = hcloud.LookupVolume(ctx, &hcloud.LookupVolumeArgs{
    			Name: pulumi.StringRef("my-volume"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = hcloud.LookupVolume(ctx, &hcloud.LookupVolumeArgs{
    			WithSelector: pulumi.StringRef("key=value"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using HCloud = Pulumi.HCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var volume1 = HCloud.GetVolume.Invoke(new()
        {
            Id = 1234,
        });
    
        var volume2 = HCloud.GetVolume.Invoke(new()
        {
            Name = "my-volume",
        });
    
        var volume3 = HCloud.GetVolume.Invoke(new()
        {
            WithSelector = "key=value",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.hcloud.HcloudFunctions;
    import com.pulumi.hcloud.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 volume1 = HcloudFunctions.getVolume(GetVolumeArgs.builder()
                .id("1234")
                .build());
    
            final var volume2 = HcloudFunctions.getVolume(GetVolumeArgs.builder()
                .name("my-volume")
                .build());
    
            final var volume3 = HcloudFunctions.getVolume(GetVolumeArgs.builder()
                .withSelector("key=value")
                .build());
    
        }
    }
    
    variables:
      volume1:
        fn::invoke:
          Function: hcloud:getVolume
          Arguments:
            id: '1234'
      volume2:
        fn::invoke:
          Function: hcloud:getVolume
          Arguments:
            name: my-volume
      volume3:
        fn::invoke:
          Function: hcloud:getVolume
          Arguments:
            withSelector: key=value
    

    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(id: Optional[int] = None,
                   location: Optional[str] = None,
                   name: Optional[str] = None,
                   selector: Optional[str] = None,
                   server_id: Optional[int] = None,
                   with_selector: Optional[str] = None,
                   with_statuses: Optional[Sequence[str]] = None,
                   opts: Optional[InvokeOptions] = None) -> GetVolumeResult
    def get_volume_output(id: Optional[pulumi.Input[int]] = None,
                   location: Optional[pulumi.Input[str]] = None,
                   name: Optional[pulumi.Input[str]] = None,
                   selector: Optional[pulumi.Input[str]] = None,
                   server_id: Optional[pulumi.Input[int]] = None,
                   with_selector: Optional[pulumi.Input[str]] = None,
                   with_statuses: Optional[pulumi.Input[Sequence[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: hcloud:index/getVolume:getVolume
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Id int
    ID of the volume.
    Location string
    (string) The location name. See the Hetzner Docs for more details about locations.
    Name string
    Name of the volume.
    Selector string

    Deprecated: Please use the with_selector property instead.

    ServerId int
    (Optional, int) Server ID the volume is attached to
    WithSelector string
    Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.
    WithStatuses List<string>
    List only volumes with the specified status, could contain creating or available.
    Id int
    ID of the volume.
    Location string
    (string) The location name. See the Hetzner Docs for more details about locations.
    Name string
    Name of the volume.
    Selector string

    Deprecated: Please use the with_selector property instead.

    ServerId int
    (Optional, int) Server ID the volume is attached to
    WithSelector string
    Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.
    WithStatuses []string
    List only volumes with the specified status, could contain creating or available.
    id Integer
    ID of the volume.
    location String
    (string) The location name. See the Hetzner Docs for more details about locations.
    name String
    Name of the volume.
    selector String

    Deprecated: Please use the with_selector property instead.

    serverId Integer
    (Optional, int) Server ID the volume is attached to
    withSelector String
    Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.
    withStatuses List<String>
    List only volumes with the specified status, could contain creating or available.
    id number
    ID of the volume.
    location string
    (string) The location name. See the Hetzner Docs for more details about locations.
    name string
    Name of the volume.
    selector string

    Deprecated: Please use the with_selector property instead.

    serverId number
    (Optional, int) Server ID the volume is attached to
    withSelector string
    Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.
    withStatuses string[]
    List only volumes with the specified status, could contain creating or available.
    id int
    ID of the volume.
    location str
    (string) The location name. See the Hetzner Docs for more details about locations.
    name str
    Name of the volume.
    selector str

    Deprecated: Please use the with_selector property instead.

    server_id int
    (Optional, int) Server ID the volume is attached to
    with_selector str
    Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.
    with_statuses Sequence[str]
    List only volumes with the specified status, could contain creating or available.
    id Number
    ID of the volume.
    location String
    (string) The location name. See the Hetzner Docs for more details about locations.
    name String
    Name of the volume.
    selector String

    Deprecated: Please use the with_selector property instead.

    serverId Number
    (Optional, int) Server ID the volume is attached to
    withSelector String
    Label Selector. For more information about possible values, visit the Hetzner Cloud Documentation.
    withStatuses List<String>
    List only volumes with the specified status, could contain creating or available.

    getVolume Result

    The following output properties are available:

    DeleteProtection bool
    (bool) Whether delete protection is enabled.
    Id int
    (int) Unique ID of the volume.
    Labels Dictionary<string, string>
    (map) User-defined labels (key-value pairs).
    LinuxDevice string
    (string) Device path on the file system for the Volume.
    Name string
    (string) Name of the volume.
    Size int
    (int) Size of the volume.
    Location string
    (string) The location name. See the Hetzner Docs for more details about locations.
    Selector string

    Deprecated: Please use the with_selector property instead.

    ServerId int
    (Optional, int) Server ID the volume is attached to
    WithSelector string
    WithStatuses List<string>
    DeleteProtection bool
    (bool) Whether delete protection is enabled.
    Id int
    (int) Unique ID of the volume.
    Labels map[string]string
    (map) User-defined labels (key-value pairs).
    LinuxDevice string
    (string) Device path on the file system for the Volume.
    Name string
    (string) Name of the volume.
    Size int
    (int) Size of the volume.
    Location string
    (string) The location name. See the Hetzner Docs for more details about locations.
    Selector string

    Deprecated: Please use the with_selector property instead.

    ServerId int
    (Optional, int) Server ID the volume is attached to
    WithSelector string
    WithStatuses []string
    deleteProtection Boolean
    (bool) Whether delete protection is enabled.
    id Integer
    (int) Unique ID of the volume.
    labels Map<String,String>
    (map) User-defined labels (key-value pairs).
    linuxDevice String
    (string) Device path on the file system for the Volume.
    name String
    (string) Name of the volume.
    size Integer
    (int) Size of the volume.
    location String
    (string) The location name. See the Hetzner Docs for more details about locations.
    selector String

    Deprecated: Please use the with_selector property instead.

    serverId Integer
    (Optional, int) Server ID the volume is attached to
    withSelector String
    withStatuses List<String>
    deleteProtection boolean
    (bool) Whether delete protection is enabled.
    id number
    (int) Unique ID of the volume.
    labels {[key: string]: string}
    (map) User-defined labels (key-value pairs).
    linuxDevice string
    (string) Device path on the file system for the Volume.
    name string
    (string) Name of the volume.
    size number
    (int) Size of the volume.
    location string
    (string) The location name. See the Hetzner Docs for more details about locations.
    selector string

    Deprecated: Please use the with_selector property instead.

    serverId number
    (Optional, int) Server ID the volume is attached to
    withSelector string
    withStatuses string[]
    delete_protection bool
    (bool) Whether delete protection is enabled.
    id int
    (int) Unique ID of the volume.
    labels Mapping[str, str]
    (map) User-defined labels (key-value pairs).
    linux_device str
    (string) Device path on the file system for the Volume.
    name str
    (string) Name of the volume.
    size int
    (int) Size of the volume.
    location str
    (string) The location name. See the Hetzner Docs for more details about locations.
    selector str

    Deprecated: Please use the with_selector property instead.

    server_id int
    (Optional, int) Server ID the volume is attached to
    with_selector str
    with_statuses Sequence[str]
    deleteProtection Boolean
    (bool) Whether delete protection is enabled.
    id Number
    (int) Unique ID of the volume.
    labels Map<String>
    (map) User-defined labels (key-value pairs).
    linuxDevice String
    (string) Device path on the file system for the Volume.
    name String
    (string) Name of the volume.
    size Number
    (int) Size of the volume.
    location String
    (string) The location name. See the Hetzner Docs for more details about locations.
    selector String

    Deprecated: Please use the with_selector property instead.

    serverId Number
    (Optional, int) Server ID the volume is attached to
    withSelector String
    withStatuses List<String>

    Package Details

    Repository
    Hetzner Cloud pulumi/pulumi-hcloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the hcloud Terraform Provider.
    hcloud logo
    Hetzner Cloud v1.21.0 published on Tuesday, Nov 12, 2024 by Pulumi