Cloudflare.VpcService reference
VpcService
Section titled “VpcService”Source:
packages/cloudflare/src/VpcService/VpcService.ts
A Cloudflare VPC service that exposes a private host (IP or hostname) reachable through a Cloudflare Tunnel for Workers VPC.
VpcService creates HTTP services. For a TCP service — e.g. a private
database that Hyperdrive connects to — use
Cloudflare.Connectivity.DirectoryService with type: "tcp".
VpcService: Creating a VPC Service
Section titled “VpcService: Creating a VPC Service”Hostname through a tunnel
const tunnel = yield* Cloudflare.Tunnel.Tunnel("MyTunnel");const service = yield* Cloudflare.VpcService.VpcService("Internal", { host: { hostname: "internal.example.com", resolverNetwork: { tunnelId: tunnel.tunnelId, resolverIps: ["10.0.0.53"] }, },});IPv4 with explicit ports
const service = yield* Cloudflare.VpcService.VpcService("DevServer", { httpPort: 5173, host: { ipv4: "192.168.1.100", network: { tunnelId: tunnel.tunnelId } },});VpcService: Looking up an existing VPC Service
Section titled “VpcService: Looking up an existing VPC Service”Look up by ID
const service = Cloudflare.VpcService.VpcService.lookup({ serviceId: "123e4567-e89b-12d3-a456-426614174000",});Bind a service looked up by name to a Worker
const worker = yield* Cloudflare.Worker("Worker", { main: "./src/worker.ts", env: { VPC: Cloudflare.VpcService.VpcService.lookup({ name: "my-vpc-service" }), },});