DigitalOcean.VPC reference
NatGateway
Section titled “NatGateway”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.
NatGateway: Routing Outbound Traffic
Section titled “NatGateway: Routing Outbound Traffic”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.
Vpc: Creating a VPC
Section titled “Vpc: Creating a VPC”const network = yield* DigitalOcean.Vpc("network", { region: "sfo3", ipRange: "10.20.0.0/20", description: "app network",});Vpc: Placing Droplets in a VPC
Section titled “Vpc: Placing Droplets in a VPC”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.VpcPeering
Section titled “VpcPeering”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.
VpcPeering: Peering Two VPCs
Section titled “VpcPeering: Peering Two VPCs”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] });