Droplets
A Droplet is a virtual machine. You choose its size (CPUs and memory, like s-1vcpu-1gb), its image (an operating system like ubuntu-24-04-x64, or a snapshot) and its region. It runs until you destroy it, and you’re billed by the hour while it exists.
A Droplet’s disk goes with it. A Volume is a network disk that outlives the Droplet and attaches to one at a time in the same region, and a snapshot saves a disk as an image to start other Droplets from.
- size
- s-1vcpu-1gb
- image
- ubuntu-24-04-x64
Create a Droplet
Section titled “Create a Droplet”In the Stack:
const key = yield* DigitalOcean.SshKey("Key", { publicKey: "ssh-ed25519 AAAA… you@laptop" });const host = yield* DigitalOcean.Droplet("Host", { region: "nyc3", size: "s-1vcpu-1gb", image: "ubuntu-24-04-x64", sshKeys: [key.fingerprint],});host.ipv4 is its public address. SSH in as root with the key.
Configure it at boot
Section titled “Configure it at boot”userData runs once on first boot, with cloud-init:
DigitalOcean.Droplet("Host", { region: "nyc3", size: "s-1vcpu-1gb", image: "ubuntu-24-04-x64", userData: `#cloud-configpackages: [nginx]runcmd: [systemctl enable --now nginx]`,});What updates in place, and what replaces
Section titled “What updates in place, and what replaces”A Droplet’s name, tags, backups and turning on IPv6 change in place. A new region, size, image, SSH keys, userData, VPC or volumes create a new Droplet and delete the old one, so keep anything that must survive on a Volume.
replaceAfter: "30 days" replaces a Droplet once it’s that old, to roll it onto a fresh image.
Keep data on a Volume
Section titled “Keep data on a Volume”const data = yield* DigitalOcean.Volume("Data", { region: "nyc3", sizeGigabytes: 10, filesystemType: "ext4",});const host = yield* DigitalOcean.Droplet("Host", { region: "nyc3", size: "s-1vcpu-1gb", image: "ubuntu-24-04-x64", volumes: [data.volumeId],});A Volume formatted with filesystemType mounts under /mnt/ on Ubuntu images. VolumeAttachment attaches one to a Droplet that already exists.
Turn on backups
Section titled “Turn on backups”DigitalOcean.Droplet("Host", { region: "nyc3", size: "s-1vcpu-1gb", image: "ubuntu-24-04-x64", backupPolicy: { plan: "daily", hour: 8 },});Daily backups are kept a week, weekly ones four weeks, and the backup window starts at hour UTC. Backups cost a share of the Droplet’s price.
Save a disk as a snapshot
Section titled “Save a disk as a snapshot”const golden = yield* DigitalOcean.DropletSnapshot("Golden", { dropletId: host.dropletId });Pass golden.snapshotId as another Droplet’s image to start from it. VolumeSnapshot does the same for a Volume.
Run a fleet with an autoscale pool
Section titled “Run a fleet with an autoscale pool”An autoscale pool keeps a group of identical Droplets, a fixed number or sized to their CPU and memory:
yield* DigitalOcean.AutoscalePool("Web", { scaling: { instances: 3 }, droplet: { region: "nyc3", size: "s-1vcpu-1gb", image: "ubuntu-24-04-x64", sshKeys: [key.fingerprint], },});Destroying the pool destroys its Droplets.
Limits
Section titled “Limits”- Changing a Droplet’s size replaces it here, rather than resizing it, so the change can’t fail half way.
- A Volume attaches to one Droplet at a time, in the same region.
alchemy destroydeletes the Droplet and its own disk. Volumes are separate resources and are deleted only when they’re removed from the Stack.
See Networking to put Droplets in a VPC and behind a firewall or load balancer.