[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-03 (世界標準時間)。"],[[["\u003cp\u003eThe \u003ccode\u003elistReferrers\u003c/code\u003e REST API method allows you to view relationships between VM instances and instance groups.\u003c/p\u003e\n"],["\u003cp\u003eUsing REST, you can identify the source resource, the target VM instance, and the type of relationship between them, such as a VM instance being a member of an instance group.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003elistReferrers\u003c/code\u003e method can display multiple referrers if a VM instance belongs to more than one instance group, providing a comprehensive list of relationships.\u003c/p\u003e\n"],["\u003cp\u003eThe method supports cross-scope relationships, allowing you to view referrers in different regions or zones, such as a VM instance belonging to a regional managed instance group.\u003c/p\u003e\n"],["\u003cp\u003eBy using the wildcard character, you can request a list of all referrers to all VM instances within a specific zone.\u003c/p\u003e\n"]]],[],null,["# Viewing referrers to VM instances\n\n*** ** * ** ***\n\nIf you want to view the relationships between VM instances and other\nCompute Engine resources, use the\n[`listReferrers` REST API method](/compute/docs/reference/rest/v1/instances/listReferrers).\n\nWhen you use REST, Compute Engine returns a list of\nreferences that describe:\n\n- The source resource: the resource that is pointing to the target resource\n- The target resource: the resource in question\n- The reference type: the relationship between the two resources\n\nFor example, you can use REST to conveniently view a list of instance\ngroups that a VM instance belongs to.\n\nBefore you begin\n----------------\n\n- If you haven't already, set up [authentication](/compute/docs/authentication). 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:\n\n\n To use the REST API samples on this page in a local development environment, you use the\n credentials you provide to the gcloud CLI.\n 1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n ```bash\n gcloud init\n ```\n 2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\n For more information, see\n [Authenticate for using REST](/docs/authentication/rest)\n in the Google Cloud authentication documentation.\n\nLimitations\n-----------\n\n- You can only list relationships between VM instances and instance groups (both managed and unmanaged).\n- You can only list referrers by using REST.\n\nListing a single referrer\n-------------------------\n\nA referrer is a resource that refers to another resource. For VM instances,\na common referrer is an instance group.\n\nFor example, assume that you have a VM instance named `example-ig-a1` in zone\n`us-central1-a`. The VM instance is a member of an instance group called\n`example-ig` in the same zone, as shown in the diagram below:\n[](/static/compute/images/instance-group-referrers-diagram.svg)\n\nTo see this relationship, call the\n[`listReferrers` method](/compute/docs/reference/v1/instances/listReferrers)\non `example-ig-a1` with the following HTTP request: \n\n GET https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/example-ig-a1/referrers\n\nThe server returns standard list response containing the following items: \n\n \"items\": [\n {\n \"target\": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/example-ig-a1,\n \"referenceType\": MEMBER_OF,\n \"referrer\": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instanceGroups/example-ig\n }\n ]\n\nIn this case, the `target` is `example-ig-a1`, which is a `MEMBER_OF`\nthe `referrer`, the `example-ig instance` group.\n\nListing multiple referrers\n--------------------------\n\nIf a resource has more than one referrer, the response returns a list\nof all referrers for the target resource. If an instance belongs to two instance\ngroups, the response contains both instance groups.\n[](/static/compute/images/instance-group-referrers-multiple-diagram.svg)\n\nFor example, the following response indicates that the instance named\n`example-instance-a2` belongs to two instance groups, `example-ig` and\n`example-ig-2`: \n\n \"items\": [\n {\n \"target\": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/example-instance-a2,\n \"referenceType\": MEMBER_OF,\n \"referrer\": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instanceGroups/example-ig\n },\n {\n \"target\": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/example-instance-a2,\n \"referenceType\": MEMBER_OF,\n \"referrer\": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instanceGroups/example-ig-2\n }\n ]\n\nListing cross-scope referrers\n-----------------------------\n\nThe `listReferrers` method also returns information about referrers that exist\ninside other scopes, such as other regions or zones. For example, assume that\nyou have a VM instance that belongs to a regional managed instance group\n(regional MIG):\n[](/static/compute/images/instance-group-referrers-cross-scope-diagram.svg)\n\nYou call the `listReferrers` method targeting this instance with the following\nHTTP request: \n\n GET https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/new-instance-a3/referrers\n\nThe server returns a standard list response containing the following items: \n\n \"items\": [\n {\n \"target\": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/new-instance-a3,\n \"referenceType\": MEMBER_OF,\n \"referrer\": https://compute.googleapis.com/compute/v1/projects/myproject/regions/us-central1/instanceGroups/example-rmig\n }\n ]\n\nThe response shows the regional instance group in the list of referrers.\n\nListing referrers to all resources within a collection\n------------------------------------------------------\n\nBy using the wildcard character (`-`), you can request a list of all\nreferrers to all VM instances within a specific zone. The request can be\nmade with an HTTP request that is similar to the following: \n\n GET https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/-/referrers\n\nThe server returns a response containing a list of VM instances in the zone\nand references to the instance. For example: \n\n \"items\": [\n {\n \"target\": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/example-ig-a1,\n \"referenceType\": MEMBER_OF,\n \"referrer\": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instanceGroups/example-ig\n },\n {\n \"target\": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/example-ig-a2,\n \"referenceType\": MEMBER_OF,\n \"referrer\": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instanceGroups/example-ig\n },\n {\n \"target\": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/example-ig-a2,\n \"referenceType\": MEMBER_OF,\n \"referrer\": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instanceGroups/example-ig-2\n },\n {\n \"target\": https://compute.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/new-instance-a3,\n \"referenceType\": MEMBER_OF,\n \"referrer\": https://compute.googleapis.com/compute/v1/projects/myproject/regions/us-central1/instanceGroups/example-rmig\n }\n ]\n\nWhat's next\n-----------\n\n- Learn more about [instance groups](/compute/docs/instance-groups).\n- See a list of applicable [zones and regions](/compute/docs/regions-zones)."]]