Skip to content

VolumeAttachment

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,
});