Skip to main content
Manage GCP virtual machines using the Compute Engine API with support for multi-project deployments and Cloud Monitoring integration.

List Virtual Machines

Retrieve all VM instances across your GCP projects.

Endpoint

GET /api/gcp/vms

Response

{
  "value": [
    {
      "provider": "GCP",
      "name": "my-instance",
      "id": "1234567890123456789",
      "status": "RUNNING",
      "location": "us-central1-a",
      "machineType": "e2-medium",
      "projectId": "my-project-id"
    }
  ]
}

Instance Status Values

status
string
  • RUNNING - Instance is running
  • STOPPED - Instance is stopped
  • TERMINATED - Instance is terminated
  • PROVISIONING - Instance is being created
  • STAGING - Resources are being allocated
  • STOPPING - Instance is shutting down

Create Virtual Machine

Provision a new GCP VM instance.

Endpoint

POST /api/gcp/vms/create

Request Parameters

projectId
string
required
GCP project ID where the instance will be created
zone
string
required
Compute Engine zone (e.g., us-central1-a, europe-west1-b)
vmName
string
required
Name for the VM instance (must match regex [a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)
machineType
string
default:"e2-medium"
Machine type (e.g., e2-small, e2-medium, n1-standard-1)
sourceImage
string
Boot disk source image

Request Example

{
  "projectId": "my-project-id",
  "zone": "us-central1-a",
  "vmName": "my-instance",
  "machineType": "e2-medium",
  "sourceImage": "projects/debian-cloud/global/images/family/debian-12"
}

Response

{
  "message": "Maszyna wirtualna 'my-instance' została pomyślnie utworzona."
}

Default Configuration

  • Machine Type: e2-medium (2 vCPUs, 4 GB memory)
  • Boot Disk Size: 10 GB
  • Boot Disk Image: Debian 12
  • Auto-delete Disk: Enabled
  • Network: global/networks/default
  • Access Config: External NAT (ephemeral external IP)
  • IP Forwarding: Disabled by default
Shared-core (E2)
  • e2-micro - 2 vCPUs (shared), 1 GB memory
  • e2-small - 2 vCPUs (shared), 2 GB memory
  • e2-medium - 2 vCPUs (shared), 4 GB memory
Standard (N1)
  • n1-standard-1 - 1 vCPU, 3.75 GB memory
  • n1-standard-2 - 2 vCPUs, 7.5 GB memory
  • n1-standard-4 - 4 vCPUs, 15 GB memory
The instance is created synchronously. The operation waits for the instance to be fully provisioned before returning.

Delete Virtual Machine

Delete a GCP VM instance.

Endpoint

POST /api/gcp/vms/delete

Request Parameters

projectId
string
required
GCP project ID
zone
string
required
Zone where the instance is located
vmName
string
required
Instance name to delete

Request Example

{
  "projectId": "my-project-id",
  "zone": "us-central1-a",
  "vmName": "my-instance"
}

Response

{
  "message": "Rozpoczęto usuwanie maszyny wirtualnej 'my-instance'."
}
The boot disk is automatically deleted if the instance was created with auto_delete=True (default behavior).

Find VM by Name

Search for a VM instance across all projects and zones.

Endpoint

GET /api/gcp/vms/find/<vm_name>

Response

{
  "projectId": "my-project-id",
  "zone": "us-central1-a",
  "vmName": "my-instance",
  "instanceId": "1234567890123456789",
  "status": "RUNNING",
  "machineType": "e2-medium",
  "resourceId": "projects/my-project-id/zones/us-central1-a/instances/my-instance"
}

Search Behavior

1

Enumerate Projects

Lists all accessible GCP projects in the authenticated account
2

Aggregate Search

Performs aggregated list across all zones in each project
3

Name Match

Returns the first instance matching the exact name
4

Resource ID

Constructs the full resource ID for monitoring and operations

Error Handling

{
  "error": "Nie znaleziono aktywnego konta GCP w sesji"
}
Cause: No active GCP account in session or missing refresh token.Solution: Authenticate through the GCP OAuth flow.

Required IAM Permissions

The service account or user must have these permissions:
# For VM operations
- compute.instances.create
- compute.instances.delete
- compute.instances.get
- compute.instances.list

# For network operations
- compute.networks.get
- compute.subnetworks.use

# For disk operations
- compute.disks.create

Code Reference

The GCP VM management implementation is located in:
  • Source: backend/gcp/vm.py:6-148
  • Dependencies: Google Cloud SDK
    • google-cloud-compute
    • google-cloud-monitoring
    • google-auth

Next Steps

VM Monitoring

Configure Cloud Monitoring metrics

Alert Policies

Set up alerts for GCP VMs

Build docs developers (and LLMs) love