hcloud.Volume
Explore with Pulumi AI
Provides a Hetzner Cloud volume resource to manage volumes.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";
const node1 = new hcloud.Server("node1", {
name: "node1",
image: "debian-11",
serverType: "cx11",
});
const master = new hcloud.Volume("master", {
name: "volume1",
size: 50,
serverId: node1.id,
automount: true,
format: "ext4",
});
import pulumi
import pulumi_hcloud as hcloud
node1 = hcloud.Server("node1",
name="node1",
image="debian-11",
server_type="cx11")
master = hcloud.Volume("master",
name="volume1",
size=50,
server_id=node1.id,
automount=True,
format="ext4")
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 {
node1, err := hcloud.NewServer(ctx, "node1", &hcloud.ServerArgs{
Name: pulumi.String("node1"),
Image: pulumi.String("debian-11"),
ServerType: pulumi.String("cx11"),
})
if err != nil {
return err
}
_, err = hcloud.NewVolume(ctx, "master", &hcloud.VolumeArgs{
Name: pulumi.String("volume1"),
Size: pulumi.Int(50),
ServerId: node1.ID(),
Automount: pulumi.Bool(true),
Format: pulumi.String("ext4"),
})
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 node1 = new HCloud.Server("node1", new()
{
Name = "node1",
Image = "debian-11",
ServerType = "cx11",
});
var master = new HCloud.Volume("master", new()
{
Name = "volume1",
Size = 50,
ServerId = node1.Id,
Automount = true,
Format = "ext4",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.hcloud.Server;
import com.pulumi.hcloud.ServerArgs;
import com.pulumi.hcloud.Volume;
import com.pulumi.hcloud.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) {
var node1 = new Server("node1", ServerArgs.builder()
.name("node1")
.image("debian-11")
.serverType("cx11")
.build());
var master = new Volume("master", VolumeArgs.builder()
.name("volume1")
.size(50)
.serverId(node1.id())
.automount(true)
.format("ext4")
.build());
}
}
resources:
node1:
type: hcloud:Server
properties:
name: node1
image: debian-11
serverType: cx11
master:
type: hcloud:Volume
properties:
name: volume1
size: 50
serverId: ${node1.id}
automount: true
format: ext4
Create Volume Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Volume(name: string, args: VolumeArgs, opts?: CustomResourceOptions);
@overload
def Volume(resource_name: str,
args: VolumeArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Volume(resource_name: str,
opts: Optional[ResourceOptions] = None,
size: Optional[int] = None,
automount: Optional[bool] = None,
delete_protection: 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)
func NewVolume(ctx *Context, name string, args VolumeArgs, opts ...ResourceOption) (*Volume, error)
public Volume(string name, VolumeArgs args, CustomResourceOptions? opts = null)
public Volume(String name, VolumeArgs args)
public Volume(String name, VolumeArgs args, CustomResourceOptions options)
type: hcloud:Volume
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- 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.
- args VolumeArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control 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.
- name String
- The unique name of the resource.
- args VolumeArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var volumeResource = new HCloud.Volume("volumeResource", new()
{
Size = 0,
Automount = false,
DeleteProtection = false,
Format = "string",
Labels =
{
{ "string", "any" },
},
Location = "string",
Name = "string",
ServerId = 0,
});
example, err := hcloud.NewVolume(ctx, "volumeResource", &hcloud.VolumeArgs{
Size: pulumi.Int(0),
Automount: pulumi.Bool(false),
DeleteProtection: pulumi.Bool(false),
Format: pulumi.String("string"),
Labels: pulumi.Map{
"string": pulumi.Any("any"),
},
Location: pulumi.String("string"),
Name: pulumi.String("string"),
ServerId: pulumi.Int(0),
})
var volumeResource = new Volume("volumeResource", VolumeArgs.builder()
.size(0)
.automount(false)
.deleteProtection(false)
.format("string")
.labels(Map.of("string", "any"))
.location("string")
.name("string")
.serverId(0)
.build());
volume_resource = hcloud.Volume("volumeResource",
size=0,
automount=False,
delete_protection=False,
format="string",
labels={
"string": "any",
},
location="string",
name="string",
server_id=0)
const volumeResource = new hcloud.Volume("volumeResource", {
size: 0,
automount: false,
deleteProtection: false,
format: "string",
labels: {
string: "any",
},
location: "string",
name: "string",
serverId: 0,
});
type: hcloud:Volume
properties:
automount: false
deleteProtection: false
format: string
labels:
string: any
location: string
name: string
serverId: 0
size: 0
Volume Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts 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).
- Delete
Protection bool Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Note: When you want to attach multiple volumes to a server, please use the
hcloud.VolumeAttachment
resource and thelocation
argument instead of theserver_id
argument.- Format string
- Format volume after creation.
xfs
orext4
- Labels Dictionary<string, object>
- (map) User-defined labels (key-value pairs).
- Location string
- The location name 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).
- Server
Id 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).
- Delete
Protection bool Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Note: When you want to attach multiple volumes to a server, please use the
hcloud.VolumeAttachment
resource and thelocation
argument instead of theserver_id
argument.- Format string
- Format volume after creation.
xfs
orext4
- Labels map[string]interface{}
- (map) User-defined labels (key-value pairs).
- Location string
- The location name 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).
- Server
Id int - Server to attach the Volume to, not allowed if location argument is passed.
- size Integer
- Size of the volume (in GB).
- automount Boolean
- Automount the volume upon attaching it (server_id must be provided).
- delete
Protection Boolean Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Note: When you want to attach multiple volumes to a server, please use the
hcloud.VolumeAttachment
resource and thelocation
argument instead of theserver_id
argument.- format String
- Format volume after creation.
xfs
orext4
- labels Map<String,Object>
- (map) User-defined labels (key-value pairs).
- location String
- The location name 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).
- server
Id Integer - 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).
- delete
Protection boolean Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Note: When you want to attach multiple volumes to a server, please use the
hcloud.VolumeAttachment
resource and thelocation
argument instead of theserver_id
argument.- format string
- Format volume after creation.
xfs
orext4
- labels {[key: string]: any}
- (map) User-defined labels (key-value pairs).
- location string
- The location name 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).
- server
Id 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).
- delete_
protection bool Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Note: When you want to attach multiple volumes to a server, please use the
hcloud.VolumeAttachment
resource and thelocation
argument instead of theserver_id
argument.- format str
- Format volume after creation.
xfs
orext4
- labels Mapping[str, Any]
- (map) User-defined labels (key-value pairs).
- location str
- The location name 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 Number
- Size of the volume (in GB).
- automount Boolean
- Automount the volume upon attaching it (server_id must be provided).
- delete
Protection Boolean Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Note: When you want to attach multiple volumes to a server, please use the
hcloud.VolumeAttachment
resource and thelocation
argument instead of theserver_id
argument.- format String
- Format volume after creation.
xfs
orext4
- labels Map<Any>
- (map) User-defined labels (key-value pairs).
- location String
- The location name 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).
- server
Id Number - 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.
- Linux
Device string - (string) Device path on the file system for the Volume.
- Id string
- The provider-assigned unique ID for this managed resource.
- Linux
Device string - (string) Device path on the file system for the Volume.
- id String
- The provider-assigned unique ID for this managed resource.
- linux
Device String - (string) Device path on the file system for the Volume.
- id string
- The provider-assigned unique ID for this managed resource.
- linux
Device string - (string) Device path on the file system for the Volume.
- id str
- The provider-assigned unique ID for this managed resource.
- linux_
device str - (string) Device path on the file system for the Volume.
- id String
- The provider-assigned unique ID for this managed resource.
- linux
Device String - (string) Device path on the file system for the Volume.
Look up 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,
delete_protection: 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)
public static Volume get(String name, Output<String> id, VolumeState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- 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.
- 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.
- Automount bool
- Automount the volume upon attaching it (server_id must be provided).
- Delete
Protection bool Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Note: When you want to attach multiple volumes to a server, please use the
hcloud.VolumeAttachment
resource and thelocation
argument instead of theserver_id
argument.- Format string
- Format volume after creation.
xfs
orext4
- Labels Dictionary<string, object>
- (map) User-defined labels (key-value pairs).
- Linux
Device string - (string) Device path on the file system for the Volume.
- Location string
- The location name 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).
- Server
Id 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).
- Delete
Protection bool Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Note: When you want to attach multiple volumes to a server, please use the
hcloud.VolumeAttachment
resource and thelocation
argument instead of theserver_id
argument.- Format string
- Format volume after creation.
xfs
orext4
- Labels map[string]interface{}
- (map) User-defined labels (key-value pairs).
- Linux
Device string - (string) Device path on the file system for the Volume.
- Location string
- The location name 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).
- Server
Id 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).
- delete
Protection Boolean Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Note: When you want to attach multiple volumes to a server, please use the
hcloud.VolumeAttachment
resource and thelocation
argument instead of theserver_id
argument.- format String
- Format volume after creation.
xfs
orext4
- labels Map<String,Object>
- (map) User-defined labels (key-value pairs).
- linux
Device String - (string) Device path on the file system for the Volume.
- location String
- The location name 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).
- server
Id Integer - Server to attach the Volume to, not allowed if location argument is passed.
- size Integer
- Size of the volume (in GB).
- automount boolean
- Automount the volume upon attaching it (server_id must be provided).
- delete
Protection boolean Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Note: When you want to attach multiple volumes to a server, please use the
hcloud.VolumeAttachment
resource and thelocation
argument instead of theserver_id
argument.- format string
- Format volume after creation.
xfs
orext4
- labels {[key: string]: any}
- (map) User-defined labels (key-value pairs).
- linux
Device string - (string) Device path on the file system for the Volume.
- location string
- The location name 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).
- server
Id 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).
- delete_
protection bool Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Note: When you want to attach multiple volumes to a server, please use the
hcloud.VolumeAttachment
resource and thelocation
argument instead of theserver_id
argument.- format str
- Format volume after creation.
xfs
orext4
- labels Mapping[str, Any]
- (map) User-defined labels (key-value pairs).
- linux_
device str - (string) Device path on the file system for the Volume.
- location str
- The location name 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).
- automount Boolean
- Automount the volume upon attaching it (server_id must be provided).
- delete
Protection Boolean Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Note: When you want to attach multiple volumes to a server, please use the
hcloud.VolumeAttachment
resource and thelocation
argument instead of theserver_id
argument.- format String
- Format volume after creation.
xfs
orext4
- labels Map<Any>
- (map) User-defined labels (key-value pairs).
- linux
Device String - (string) Device path on the file system for the Volume.
- location String
- The location name 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).
- server
Id Number - Server to attach the Volume to, not allowed if location argument is passed.
- size Number
- Size of the volume (in GB).
Import
Volumes can be imported using their id
:
$ pulumi import hcloud:index/volume:Volume myvolume id
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Hetzner Cloud pulumi/pulumi-hcloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
hcloud
Terraform Provider.