Skip to content

Hetzner.Volume reference

Source: src/Hetzner/MountVolume.ts

Mount a Hetzner Volume into a Service.

yield* Hetzner.MountVolume(volume, { path: "/data" }) inside a Service impl registers { env, volumes: [{ volumeId, path }] } on the host. Service reconcile attaches the Volume (no automount) and SSHs mkdir + mount + fstab at path. The same (volume, server, path) from two Services is one attach and one mount.

const volume = yield* Hetzner.Volume("data", {
size: 10,
format: "ext4",
location: "nbg1",
});
const mount = yield* Hetzner.MountVolume(volume, { path: "/data" });
// mount.path === "/data"
// mount.device === volume.linuxDevice

Source: src/Hetzner/Volume.ts

A Hetzner Cloud Volume — a network block device that can be attached to a Server in the same Location. Unattached Volumes are valid; pass server to attach at create time.

Size can grow in place (min 10 GB). Format and location are immutable (changing either replaces the Volume). Hetzner cannot shrink a Volume.

Unattached Volume

const volume = yield* Hetzner.Volume("data", {
size: 10,
format: "ext4",
location: "nbg1",
});

Named Volume with labels

const volume = yield* Hetzner.Volume("data", {
name: "app-data",
size: 20,
format: "xfs",
location: "nbg1",
labels: { role: "db" },
});
const server = yield* Hetzner.Server("web", {
serverType: "cx22",
image: "ubuntu-24.04",
location: "nbg1",
});
const volume = yield* Hetzner.Volume("data", {
size: 10,
format: "ext4",
server,
automount: true,
});

Source: src/Hetzner/VolumeAttachment.ts

Attaches a Hetzner Cloud Volume to a Server in the same Location. The Volume and Server must already exist. Deleting the attachment detaches the Volume; it does not delete the Volume or the Server.

This is an existence-style resource — its identity is the volume/server pair. Changing either replaces the attachment. automount updates in place (detach + re-attach).

Attach a Volume to a Server

const server = yield* Hetzner.Server("web", {
serverType: "cx23",
image: "ubuntu-24.04",
location: "nbg1",
});
const volume = yield* Hetzner.Volume("data", {
size: 10,
format: "ext4",
location: "nbg1",
});
const attachment = yield* Hetzner.VolumeAttachment("data-attach", {
volume,
server,
});

Attach with automount

const attachment = yield* Hetzner.VolumeAttachment("data-attach", {
volume,
server,
automount: true,
});