Get the ID of a VM instance

Stay organized with collections Save and categorize content based on your preferences.

A virtual machine (VM) instance's ID lets you reference it with an immutable value.

Before you begin

Get the ID of a VM instance

Console

  1. Go to the VM instances page.

    Go to VM instances

  2. Click the Name of the VM instance.

  3. In Basic information > Instance Id, view the VM instance ID.

gcloud

Get the instance ID by using the gcloud compute instances describe command. This command returns the instance ID as a string in the id field.

gcloud compute instances describe INSTANCE_NAME

Replace INSTANCE_NAME with the name of the instance.

API

Get the instance ID by using the instances.get method. This method returns the instance ID as a string value for the id in the response body.

GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME

Replace the following:

  • PROJECT_ID: ID of the project containing the instance to get the ID of

  • ZONE: zone containing the instance to get the ID of

  • INSTANCE_NAME: name of the instance to get the ID of

What's next