DigitalOcean.Droplets reference
AutoscalePool
Section titled “AutoscalePool”Source:
packages/digitalocean/src/AutoscalePool.ts
A DigitalOcean Droplet autoscale pool: a fleet of identical droplets kept at a fixed count or scaled by CPU or memory utilization. Put a load balancer in front by targeting the pool’s droplet tag. Every prop updates in place.
AutoscalePool: Scaling Droplets
Section titled “AutoscalePool: Scaling Droplets”const publicKey = yield* Config.string("SSH_KEY");const key = yield* DigitalOcean.SshKey("deploy", { publicKey });const pool = yield* DigitalOcean.AutoscalePool("web", { scaling: { minInstances: 2, maxInstances: 10, targetCpuUtilization: 0.6 }, droplet: { region: "nyc3", size: "s-1vcpu-1gb", image: "ubuntu-24-04-x64", sshKeys: [key.fingerprint], tags: ["web"], userData: "#cloud-config\npackages: [nginx]", },});yield* DigitalOcean.LoadBalancer("web-lb", { region: "nyc3", forwardingRules: [{ entryProtocol: "http", entryPort: 80, targetProtocol: "http", targetPort: 80 }], tag: "web",});Droplet
Section titled “Droplet”Source:
packages/digitalocean/src/Droplet.ts
A DigitalOcean Droplet: a Linux virtual machine. name and tags
update in place, and so does enabling ipv6. A change to any other
property replaces the droplet, creating the new one before deleting the
old one unless it holds volumes. Put all setup in userData
(cloud-init) so a new droplet configures itself.
Droplet names are not unique. Alchemy tags every droplet it creates with
an alchemy: ownership tag, built from the stack, stage and
fully-qualified resource name, and an alchemy:generation: tag for the
generation, so an interrupted deploy resumes on the droplet it already
created and a replacement never mistakes the old droplet for the new one.
A same-named droplet without the ownership tag is Unowned and needs
--adopt.
Droplet: Creating a Droplet
Section titled “Droplet: Creating a Droplet”Host reachable over SSH
const key = yield* DigitalOcean.SshKey("deploy-key", { publicKey: yield* Config.String("SSH_PUBLIC_KEY"),});const host = yield* DigitalOcean.Droplet("app", { region: "sfo3", size: "s-2vcpu-4gb", image: "ubuntu-24-04-x64", sshKeys: [key.fingerprint], monitoring: true,});Bootstrap via cloud-init
const host = yield* DigitalOcean.Droplet("app", { region: "sfo3", size: "s-2vcpu-4gb", image: "ubuntu-24-04-x64", userData: [ "#cloud-config", "packages: [docker.io]", "runcmd:", " - docker run -d --restart=always -p 80:80 nginx", ].join("\n"),});Droplet: Replacing on a Schedule
Section titled “Droplet: Replacing on a Schedule”const host = yield* DigitalOcean.Droplet("app", { region: "sfo3", size: "s-2vcpu-4gb", image: "ubuntu-24-04-x64", // After 30 days the next deploy creates a new droplet with a new IP. replaceAfter: "30 days", userData: "#cloud-config\npackages: [docker.io]",});Droplet: Tagging
Section titled “Droplet: Tagging”const host = yield* DigitalOcean.Droplet("app", { region: "sfo3", size: "s-2vcpu-4gb", image: "ubuntu-24-04-x64", tags: ["web"],});// A firewall given `host.tags` waits for the droplet to create the tag.DropletSnapshot
Section titled “DropletSnapshot”Source:
packages/digitalocean/src/DropletSnapshot.ts
A snapshot of a Droplet’s disk, taken once when the resource is created.
Boot new Droplets from it by passing snapshotId as their image. The
Droplet keeps running while the snapshot is taken.
DropletSnapshot: Taking a Snapshot
Section titled “DropletSnapshot: Taking a Snapshot”const snap = yield* DigitalOcean.DropletSnapshot("golden", { dropletId: host.dropletId,});yield* DigitalOcean.Droplet("clone", { region: "nyc3", size: "s-1vcpu-1gb", image: snap.snapshotId,});