Skip to content

DigitalOcean.VPC reference

Source: packages/digitalocean/src/NatGateway.ts

A DigitalOcean VPC NAT gateway: droplets in the VPCs reach the internet through it, from a fixed public address, without public IPs of their own. VPCs, size, timeouts and the name update in place; region replaces the gateway.

const network = yield* DigitalOcean.Vpc("network", { region: "nyc3" });
const nat = yield* DigitalOcean.NatGateway("egress", {
region: "nyc3",
vpcIds: [network.vpcId],
});
// Allow nat.egressIps in third-party firewalls.

Source: packages/digitalocean/src/Vpc.ts

A DigitalOcean VPC: a private network for droplets, Kubernetes clusters, load balancers and databases in one region. Resources in the same VPC reach each other on private addresses. name and description update in place; region and ipRange replace the VPC.

A VPC has no tags. Alchemy owns a VPC whose name it generated, or whose id it recorded. A VPC that already has the chosen name is Unowned and needs --adopt.

DigitalOcean makes the first VPC in a region the region’s default, and a default VPC cannot be deleted (VpcIsDefault). Declare VPCs in regions that already have a default VPC (any region where the team has run a droplet), or expect the first one to stay.

const network = yield* DigitalOcean.Vpc("network", {
region: "sfo3",
ipRange: "10.20.0.0/20",
description: "app network",
});
const network = yield* DigitalOcean.Vpc("network", { region: "sfo3" });
const host = yield* DigitalOcean.Droplet("app", {
region: "sfo3",
size: "s-1vcpu-1gb",
image: "ubuntu-24-04-x64",
vpcUuid: network.vpcId,
});
// host.privateIpv4 is an address in network.ipRange.

Source: packages/digitalocean/src/VpcPeering.ts

A DigitalOcean VPC peering: routes private traffic between two VPCs, also across regions. Their IP ranges must not overlap. A new vpcIds pair replaces the peering; name updates in place.

const nyc = yield* DigitalOcean.Vpc("nyc", { region: "nyc3", ipRange: "10.10.0.0/20" });
const ams = yield* DigitalOcean.Vpc("ams", { region: "ams3", ipRange: "10.20.0.0/20" });
yield* DigitalOcean.VpcPeering("nyc-ams", { vpcIds: [nyc.vpcId, ams.vpcId] });