Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

Volume

Provides a Hetzner Cloud volume resource to manage volumes.

Example Usage

using Pulumi;
using HCloud = Pulumi.HCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var node1 = new HCloud.Server("node1", new HCloud.ServerArgs
        {
            Image = "debian-9",
            ServerType = "cx11",
        });
        var master = new HCloud.Volume("master", new HCloud.VolumeArgs
        {
            Size = 50,
            ServerId = node1.Id,
            Automount = true,
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-hcloud/sdk/go/hcloud"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        node1, err := hcloud.NewServer(ctx, "node1", &hcloud.ServerArgs{
            Image:      pulumi.String("debian-9"),
            ServerType: pulumi.String("cx11"),
        })
        if err != nil {
            return err
        }
        _, err = hcloud.NewVolume(ctx, "master", &hcloud.VolumeArgs{
            Size:      pulumi.Int(50),
            ServerId:  node1.ID(),
            Automount: pulumi.Bool(true),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_hcloud as hcloud

node1 = hcloud.Server("node1",
    image="debian-9",
    server_type="cx11")
master = hcloud.Volume("master",
    size=50,
    server_id=node1.id,
    automount=True)
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";

const node1 = new hcloud.Server("node1", {
    image: "debian-9",
    serverType: "cx11",
});
const master = new hcloud.Volume("master", {
    size: 50,
    serverId: node1.id,
    automount: true,
});

Create a Volume Resource

new Volume(name: string, args: VolumeArgs, opts?: CustomResourceOptions);
def Volume(resource_name: str, opts: Optional[ResourceOptions] = None, automount: Optional[bool] = None, format: Optional[str] = None, labels: Optional[Mapping[str, Any]] = None, location: Optional[str] = None, name: Optional[str] = None, server_id: Optional[int] = None, size: Optional[int] = None)
func NewVolume(ctx *Context, name string, args VolumeArgs, opts ...ResourceOption) (*Volume, error)
public Volume(string name, VolumeArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args VolumeArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args VolumeArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args VolumeArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Volume Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The Volume resource accepts the following input properties:

Size int

Size of the volume (in GB).

Automount bool

Automount the volume upon attaching it (server_id must be provided).

Format string

Format volume after creation. xfs or ext4

Labels Dictionary<string, object>

User-defined labels (key-value pairs).

Location string

Location of the volume to create, not allowed if server_id argument is passed.

Name string

Name of the volume to create (must be unique per project).

ServerId int

Server to attach the Volume to, not allowed if location argument is passed.

Size int

Size of the volume (in GB).

Automount bool

Automount the volume upon attaching it (server_id must be provided).

Format string

Format volume after creation. xfs or ext4

Labels map[string]interface{}

User-defined labels (key-value pairs).

Location string

Location of the volume to create, not allowed if server_id argument is passed.

Name string

Name of the volume to create (must be unique per project).

ServerId int

Server to attach the Volume to, not allowed if location argument is passed.

size number

Size of the volume (in GB).

automount boolean

Automount the volume upon attaching it (server_id must be provided).

format string

Format volume after creation. xfs or ext4

labels {[key: string]: any}

User-defined labels (key-value pairs).

location string

Location of the volume to create, not allowed if server_id argument is passed.

name string

Name of the volume to create (must be unique per project).

serverId number

Server to attach the Volume to, not allowed if location argument is passed.

size int

Size of the volume (in GB).

automount bool

Automount the volume upon attaching it (server_id must be provided).

format str

Format volume after creation. xfs or ext4

labels Mapping[str, Any]

User-defined labels (key-value pairs).

location str

Location of the volume to create, not allowed if server_id argument is passed.

name str

Name of the volume to create (must be unique per project).

server_id int

Server to attach the Volume to, not allowed if location argument is passed.

Outputs

All input properties are implicitly available as output properties. Additionally, the Volume resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
LinuxDevice string

Device path on the file system for the Volume.

Id string
The provider-assigned unique ID for this managed resource.
LinuxDevice string

Device path on the file system for the Volume.

id string
The provider-assigned unique ID for this managed resource.
linuxDevice string

Device path on the file system for the Volume.

id str
The provider-assigned unique ID for this managed resource.
linux_device str

Device path on the file system for the Volume.

Look up an Existing Volume Resource

Get an existing Volume resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: VolumeState, opts?: CustomResourceOptions): Volume
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, automount: Optional[bool] = None, format: Optional[str] = None, labels: Optional[Mapping[str, Any]] = None, linux_device: Optional[str] = None, location: Optional[str] = None, name: Optional[str] = None, server_id: Optional[int] = None, size: Optional[int] = None) -> Volume
func GetVolume(ctx *Context, name string, id IDInput, state *VolumeState, opts ...ResourceOption) (*Volume, error)
public static Volume Get(string name, Input<string> id, VolumeState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Automount bool

Automount the volume upon attaching it (server_id must be provided).

Format string

Format volume after creation. xfs or ext4

Labels Dictionary<string, object>

User-defined labels (key-value pairs).

LinuxDevice string

Device path on the file system for the Volume.

Location string

Location of the volume to create, not allowed if server_id argument is passed.

Name string

Name of the volume to create (must be unique per project).

ServerId int

Server to attach the Volume to, not allowed if location argument is passed.

Size int

Size of the volume (in GB).

Automount bool

Automount the volume upon attaching it (server_id must be provided).

Format string

Format volume after creation. xfs or ext4

Labels map[string]interface{}

User-defined labels (key-value pairs).

LinuxDevice string

Device path on the file system for the Volume.

Location string

Location of the volume to create, not allowed if server_id argument is passed.

Name string

Name of the volume to create (must be unique per project).

ServerId int

Server to attach the Volume to, not allowed if location argument is passed.

Size int

Size of the volume (in GB).

automount boolean

Automount the volume upon attaching it (server_id must be provided).

format string

Format volume after creation. xfs or ext4

labels {[key: string]: any}

User-defined labels (key-value pairs).

linuxDevice string

Device path on the file system for the Volume.

location string

Location of the volume to create, not allowed if server_id argument is passed.

name string

Name of the volume to create (must be unique per project).

serverId number

Server to attach the Volume to, not allowed if location argument is passed.

size number

Size of the volume (in GB).

automount bool

Automount the volume upon attaching it (server_id must be provided).

format str

Format volume after creation. xfs or ext4

labels Mapping[str, Any]

User-defined labels (key-value pairs).

linux_device str

Device path on the file system for the Volume.

location str

Location of the volume to create, not allowed if server_id argument is passed.

name str

Name of the volume to create (must be unique per project).

server_id int

Server to attach the Volume to, not allowed if location argument is passed.

size int

Size of the volume (in GB).

Import

Volumes can be imported using their id

 $ pulumi import hcloud:index/volume:Volume myvolume <id>

Package Details

Repository
https://github.com/pulumi/pulumi-hcloud
License
Apache-2.0
Notes
This Pulumi package is based on the hcloud Terraform Provider.