Viewing referrers to VM instances Stay organized with collections Save and categorize content based on your preferences.
If you want to view the relationships between VM instances and otherCompute Engine resources, use thelistReferrers REST API method.
When you use REST, Compute Engine returns a list ofreferences that describe:
- The source resource: the resource that is pointing to the target resource
- The target resource: the resource in question
- The reference type: the relationship between the two resources
For example, you can use REST to conveniently view a list of instancegroups that a VM instance belongs to.
Before you begin
- If you haven't already, set upauthentication. Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.For more information, seeAuthenticate for using REST in the Google Cloud authentication documentation.
Limitations
- You can only list relationships between VM instances and instance groups (bothmanaged and unmanaged).
- You can only list referrers by using REST.
Listing a single referrer
A referrer is a resource that refers to another resource. For VM instances,a common referrer is an instance group.
For example, assume that you have a VM instance namedexample-ig-a1 in zoneus-central1-a. The VM instance is a member of an instance group calledexample-ig in the same zone, as shown in the diagram below:
To see this relationship, call thelistReferrers methodonexample-ig-a1 with the following HTTP request:
GET https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/example-ig-a1/referrersThe server returns standard list response containing the following items:
"items": [ { "target": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/example-ig-a1, "referenceType": MEMBER_OF, "referrer": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instanceGroups/example-ig }]In this case, thetarget isexample-ig-a1, which is aMEMBER_OFthereferrer, theexample-ig instance group.
Listing multiple referrers
If a resource has more than one referrer, the response returns a listof all referrers for the target resource. If an instance belongs to two instancegroups, the response contains both instance groups.
For example, the following response indicates that the instance namedexample-instance-a2 belongs to two instance groups,example-ig andexample-ig-2:
"items": [ { "target": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/example-instance-a2, "referenceType": MEMBER_OF, "referrer": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instanceGroups/example-ig }, { "target": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/example-instance-a2, "referenceType": MEMBER_OF, "referrer": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instanceGroups/example-ig-2 }]Listing cross-scope referrers
ThelistReferrers method also returns information about referrers that existinside other scopes, such as other regions or zones. For example, assume thatyou have a VM instance that belongs to a regional managed instance group(regional MIG):
You call thelistReferrers method targeting this instance with the followingHTTP request:
GET https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/new-instance-a3/referrersThe server returns a standard list response containing the following items:
"items":[{"target":https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/new-instance-a3,"referenceType":MEMBER_OF,"referrer":https://compute.googleapis.com/compute/v1/projects/myproject/regions/us-central1/instanceGroups/example-rmig}]The response shows the regional instance group in the list of referrers.
Listing referrers to all resources within a collection
By using the wildcard character (-), you can request a list of allreferrers to all VM instances within a specific zone. The request can bemade with an HTTP request that is similar to the following:
GET https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/-/referrersThe server returns a response containing a list of VM instances in the zoneand references to the instance. For example:
"items":[{"target":https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/example-ig-a1,"referenceType":MEMBER_OF,"referrer":https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instanceGroups/example-ig},{"target":https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/example-ig-a2,"referenceType":MEMBER_OF,"referrer":https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instanceGroups/example-ig},{"target":https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/example-ig-a2,"referenceType":MEMBER_OF,"referrer":https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instanceGroups/example-ig-2},{"target":https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/new-instance-a3,"referenceType":MEMBER_OF,"referrer":https://compute.googleapis.com/compute/v1/projects/myproject/regions/us-central1/instanceGroups/example-rmig}]What's next
- Learn more aboutinstance groups.
- See a list of applicablezones and regions.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.