Skip to content
betterstack-alchemyUnofficial

Cloud.Volume

Kind ResourceType id BetterStack.Cloud.VolumeSource src/Cloud/Volume.tsLive test gated Lifecycle test runs against the offline mock; a live run exists but is gated behind BETTERSTACK_TEST_CLOUD_SERVER=1 because it runs live only in the shared server suite (test/Cloud/live), one billed server per run (test/Cloud/Volume.test.ts).

An NVMe block volume, attached to one server at a time, from 1 to 3072 GiB, billed per allocated GiB whether attached or not.

The volume is created attached to serverId and the deploy waits until it is. sizeGb grows in place (resize_volume, then a wait); a volume never shrinks, so a smaller sizeGb fails with VolumeShrinkRefused before anything changes. serverId moves or (null) detaches it in place. format, autoMount, volumeType and availabilityZone replace the volume; name and metadata change in place. Deleting detaches it first and waits until it is gone.

With format and autoMount: true the server mounts the volume under /mnt (see mountPath); devicePath is the stable device for /etc/fstab.

Ownership. Every object the stack creates carries an alchemy entry in its metadata (<stack>/<stage>/<resource id>#<instance>), added on every write and left out of the attributes and of diffs; your own keys are untouched (it takes one of the 10 slots). A deploy that lost track of an object it created (a create that failed or timed out after the API accepted it) finds it by that marker and converges it instead of creating another; list (and so alchemy nuke) returns only Alchemy-created objects; an object with the same name but no marker of this resource is taken over only with --adopt.

PaymentRequired on the first create. The first billable create of an account can be refused with a typed PaymentRequired (HTTP 402 payment_required) whose message carries a payment link. Paying through that link creates the object FROM THE REFUSED REQUEST, later and outside the deploy (observed live 2026-12-01 for a server). Deploy again after paying: the deploy finds the object by its ownership marker and converges it instead of creating a second one.

Verified live (2026-12-01): create attached (1 GiB, ext4), grow to 2 GiB, detach (serverId: null), re-attach, mounted by Cloud.MountVolume at a custom path, delete. NOT live-verified: moving between servers, replacement, autoMount: false, xfs.

A formatted volume mounted on a server

const volume = yield* BetterStack.Cloud.Volume("data", {
serverId: server.id,
sizeGb: 10,
format: "ext4",
autoMount: true,
});

Grow to 20 GiB and move to another server

yield* BetterStack.Cloud.Volume("data", {
serverId: other.id,
sizeGb: 20,
format: "ext4",
autoMount: true,
});

Detach

yield* BetterStack.Cloud.Volume("data", { serverId: null, sizeGb: 20, format: "ext4", autoMount: true });

sizeGb number required

The volume's size in GiB, from 1 to 3072. Can't shrink.

autoMount boolean

Whether the server mounts the volume automatically when it's attached. Needs a format.

availabilityZone string

Availability zone the resource lives in, such as us-west-2a. Defaults to the credentials' zone (BETTERSTACK_AVAILABILITY_ZONE, or the profile's). Changing it replaces the resource. A child of a resource in another zone (a firewall rule, a node pool, a snapshot of an instance outside the credentials' zone) must repeat the parent's availabilityZone: it receives only the parent's id, so its zone cannot be derived.

format "ext4" | "xfs" | string

The filesystem we created on the volume, or null for a volume without a filesystem.

metadata CreateVolumeRequestMetadataMap

Your own tags, as string keys and values, at most 10. An update replaces all tags. Set it to an empty object to remove them all.

name string

The volume's name, unique among the organization's volumes. Defaults to a unique name generated from the stack, stage and logical id. Changes in place.

serverId string | null

The server the volume is attached to. Required when the volume is created (the Cloud API creates volumes attached). Afterwards a new value moves the volume (detach, then attach; its data moves when the server is on another host), null detaches it, and leaving it out leaves the attachment to whatever else manages it (e.g. Cloud.MountVolume).

volumeType "nvme" | string

The kind of storage, always nvme.

availabilityZone string always set

Availability zone the resource lives in, such as us-west-2a.

id string always set

The volume's ID.

autoMount boolean

Whether the server mounts the volume automatically when it's attached. Needs a format.

createdAt string

When the volume was created.

devicePath string | null

The volume's device path on the server, under /dev/disk/by-id. Use the device path in /etc/fstab, since it doesn't change. Stays null while the volume isn't attached.

failureReason string | null

Why the last change to the volume failed, such as an attach, detach or resize. The reason stays after the volume is back to available or attached.

format "ext4" | "xfs" | null

The filesystem we created on the volume, or null for a volume without a filesystem.

lock VolumeLock | null

Our lock on the volume, or null. A locked volume can't be changed. Every change is refused with the error code locked.

metadata VolumeMetadataMap

Your own tags, as string keys and values, at most 10. An update replaces all tags. Set it to an empty object to remove them all.

mountPath string | null

Where the server mounts the volume, under /mnt, or null when the volume isn't mounted.

name string

The volume's name. Must be unique among the organization's volumes. A deleted volume's name can be used again.

serverId string | null

The ID of the server the volume is attached to, or null when the volume isn't attached. The server must be running or stopped.

sizeGb number

The volume's size in GiB, from 1 to 3072. Can't shrink.

status string

The volume's state. While a change to the volume is in progress, other changes to it are refused. - creating: We're creating the volume. - attaching: We're attaching the volume to a server. - attached: The volume is attached to a server. - detaching: We're detaching the volume. - available: The volume isn't attached to a server. A new volume that ends up available couldn't be attached, and failure_reason says why. - moving: We're copying the volume to the host of the server you're attaching it to. - resizing: We're growing the volume. - snapshotting: We're creating a snapshot of the volume. - deleting: We're deleting the volume. - failed: We couldn't create the volume. A failed volume stays in this state. - destroyed: The volume is deleted.

teamId string

The ID of the team that owns the volume. A volume belongs to the team of the server you created it on.

updatedAt string

When the volume was last updated.

volumeType "nvme"

The kind of storage, always nvme.

Volume.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.

availabilityZone string

Zone it lives in, such as us-west-2a. Defaults to the credentials' zone.