fix(gcp): add network/subnet flags to fix custom VPC subnet mode (#1883)

GCP instance creation was failing with 'Invalid value for field
resource.networkInterfaces[0].subnetwork' when the project VPC uses
custom subnet mode. Add --network and --subnet flags defaulting to
'default', with GCP_NETWORK and GCP_SUBNET env var overrides for
custom VPC setups.

Fixes #1882

Agent: issue-fixer

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
A 2026-02-24 11:27:46 -08:00 committed by GitHub
parent 5ffa0f663b
commit 2a1ed4164e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 1 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@openrouter/spawn",
"version": "0.10.4",
"version": "0.10.5",
"type": "module",
"bin": {
"spawn": "cli.js"

View file

@ -673,6 +673,9 @@ export async function createInstance(
`--machine-type=${machineType}`,
"--image-family=ubuntu-2404-lts-amd64",
"--image-project=ubuntu-os-cloud",
`--network=${process.env.GCP_NETWORK ?? "default"}`,
`--subnet=${process.env.GCP_SUBNET ?? "default"}`,
`--subnet-region=${zone.replace(/-[a-z]$/, "")}`,
`--metadata-from-file=startup-script=${tmpFile}`,
`--metadata=ssh-keys=${sshKeysMetadata}`,
`--project=${gcpProject}`,

View file

@ -49,3 +49,20 @@ GCP_INSTANCE_NAME=dev-mk1 \
OPENROUTER_API_KEY=sk-or-v1-xxxxx \
bash <(curl -fsSL https://openrouter.ai/labs/spawn/gcp/claude.sh)
```
## Custom VPC / Subnet
If your GCP project's default VPC uses **custom subnet mode** (common in enterprise or org-managed projects), set these env vars to override the default network/subnet:
| Variable | Default | Description |
|---|---|---|
| `GCP_NETWORK` | `default` | VPC network name |
| `GCP_SUBNET` | `default` | Subnet name |
Example:
```bash
GCP_NETWORK=my-vpc GCP_SUBNET=my-subnet \
GCP_INSTANCE_NAME=dev-mk1 \
OPENROUTER_API_KEY=sk-or-v1-xxxxx \
bash <(curl -fsSL https://openrouter.ai/labs/spawn/gcp/claude.sh)
```