Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/wvpc-192-vpc-network-commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"wrangler": minor
---

Add `wrangler vpc network` commands for managing VPC networks

New CLI commands for creating and managing VPC networks:

- `wrangler vpc network create <name>` — create a network with a required `--tunnel-id` and optional `--resolver-ips`
- `wrangler vpc network list` — list all networks for the account
- `wrangler vpc network get <network-id>` — retrieve a single network by ID
- `wrangler vpc network update <network-id>` — update name and/or resolver IPs
- `wrangler vpc network delete <network-id>` — delete a network

Also lifts the restriction that required `network_id` in `vpc_networks` bindings to equal `"cf1:network"` — any string value is now accepted, enabling bindings to explicitly created network entities.
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,60 @@ const testCases: TestCase[] = [
expect.stringMatching(/ProxyError.*ProxyError/),
],
},
{
name: "VPC Network (UUID)",
scriptPath: "vpc-network-uuid.js",
setup: async (helper) => {
const networkName = generateResourceName();

// Create a real Cloudflare tunnel for testing
const tunnelId = await helper.tunnel();

const output = await helper.run(
`wrangler vpc network create ${networkName} --tunnel-id ${tunnelId}`
);

// Extract network_id from output: "✅ Created VPC network: <uuid>"
const match = output.stdout.match(
/Created VPC network:\s+(?<networkId>[\w-]+)/
);
const networkId = match?.groups?.networkId;
assert(
networkId,
"Failed to extract network ID from VPC network creation output"
);

// Teardown runs LIFO: network is deleted before its tunnel.
helper.onTeardown(async () => {
await helper.run(`wrangler vpc network delete ${networkId}`);
});

return {
remoteProxySessionConfig: {
bindings: {
VPC_NETWORK_UUID: {
type: "vpc_network",
network_id: networkId,
},
} as unknown as StartDevWorkerInput["bindings"],
},
miniflareConfig: (connection) =>
({
vpcNetworks: {
VPC_NETWORK_UUID: {
network_id: networkId,
remoteProxyConnectionString: connection,
},
},
}) as unknown as Partial<WorkerOptions>,
};
},
getExpectFetchToMatch: (expect) => [
// Tunnel has no running cloudflared connector, so the internal service
// returns a ProxyError — proving the UUID network binding was wired correctly.
expect.stringContaining("ProxyError"),
],
},
{
name: "VPC Service",
scriptPath: "vpc-service.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default {
async fetch(request, env, ctx) {
const results = {};
try {
const response = await env.VPC_NETWORK_UUID.fetch(
"http://10.0.0.1:8080/"
);
results.VPC_NETWORK_UUID = await response.text();
} catch (e) {
const name = e.constructor?.name ?? "Error";
results.VPC_NETWORK_UUID = `${name}: ${e.message}`;
}
return new Response(JSON.stringify(results));
},
};
Loading
Loading