ERROR: (gcloud.compute.interconnects.attachments.partner.create) Could not fetch resource:
- Constraint constraints/compute.restrictPartnerInterconnectUsage violated for projects/example-project.
projects/example-project/global/networks/example-network is not allowed to use the Partner Interconnect.
[[["容易理解","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-05 (世界標準時間)。"],[],[],null,["# Restrict Cloud Interconnect usage\n\nThis document describes how to restrict the set of Virtual Private Cloud (VPC)\nnetworks that can use Cloud Interconnect.\n\nBy default, any VPC network can use Cloud Interconnect.\nTo control which VPC networks can use Cloud Interconnect,\nyou can set an organization policy. For general information about organization\npolicies, see\n[Introduction to the Organization Policy Service](/resource-manager/docs/organization-policy/overview).\n\nUsing Cloud Interconnect to connect a VPC network to\nyour on-premises network requires a\n[VLAN attachment](/network-connectivity/docs/interconnect/how-to/dedicated/creating-vlan-attachments).\nAn organization policy for restricting Cloud Interconnect\nusage allows or denies the creation of VLAN attachments from specified\nVPC networks. You can set a policy that allows or denies the\ncreation of VLAN attachments from a specific VPC network or all\nVPC networks in a project, folder, or organization resource.\n\nYou can use the following constraints when defining your policy:\n\n- `constraints/compute.restrictDedicatedInterconnectUsage`\n\n This constraint defines the set of VPC networks that you can\n use when creating a VLAN attachment using Dedicated Interconnect.\n- `constraints/compute.restrictPartnerInterconnectUsage`\n\n This constraint defines the set of VPC networks that you can\n use when creating a VLAN attachment using Partner Interconnect.\n\nWhen you set an organization policy, it only constrains the creation of VLAN\nattachments in the future. The policy does not affect previously created VLAN\nattachments.\n\nIf a user attempts to create a VLAN attachment that violates an organization\npolicy, they see an error message. The following is an example error message\nfrom running `gcloud compute interconnects attachments partner create`: \n\n```\nERROR: (gcloud.compute.interconnects.attachments.partner.create) Could not fetch resource:\n- Constraint constraints/compute.restrictPartnerInterconnectUsage violated for projects/example-project.\nprojects/example-project/global/networks/example-network is not allowed to use the Partner Interconnect.\n```\n\nThis page includes example procedures for setting organization policies\nto restrict Cloud Interconnect usage.\n\nFor more information, including general procedures for setting organization\npolicies, see the following:\n\n- [Understanding constraints](/resource-manager/docs/organization-policy/understanding-constraints)\n- [Using constraints](/resource-manager/docs/organization-policy/using-constraints)\n- [Creating and managing organization policies](/resource-manager/docs/organization-policy/creating-managing-policies)\n\nBefore you begin\n----------------\n\nTo set organization policies, you must have the\n[Organization Policy Administrator role](/iam/docs/understanding-roles#organization-policy-roles)\n(`roles/orgpolicy.policyAdmin`).\n\nSet a policy to deny a specific VPC network\n-------------------------------------------\n\nTo set a policy to deny a specific VPC network from using\nCloud Interconnect, follow these steps:\n\n1. Find your organization ID by entering the following command:\n\n ```\n gcloud organizations list\n ```\n\n The command output looks like the following example: \n\n ```\n DISPLAY NAME ID\n example-organization 29252605212\n ```\n2. Create a JSON file that defines your policy. The following example JSON\n file defines a policy that prevents `network-1` in `project-1` from using\n Dedicated Interconnect:\n\n ```\n {\n \"Constraint\": \"constraints/compute.restrictDedicatedInterconnectUsage\",\n \"listPolicy\": {\n \"deniedValues\": [\n \"projects/project-1/global/networks/network-1\"\n ]\n }\n }\n ```\n3. Use the `gcloud` Resource Manager `set-policy` command to set the organization\n policy:\n\n ```\n gcloud resource-manager org-policies set-policy JSON_FILE_NAME\n --organization=ORGANIZATION_ID\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eJSON_FILE_NAME\u003c/var\u003e: the name of the JSON file that you\n created in the previous step, such as `policy-name.json`\n\n - \u003cvar translate=\"no\"\u003eORGANIZATION_ID\u003c/var\u003e: the ID of the organization that you\n previously found\n\nSet a policy to deny all VPC networks\n-------------------------------------\n\nTo set a policy to deny all VPC networks from using\nCloud Interconnect, follow these steps:\n\n1. Find your organization ID by entering the following command:\n\n ```\n gcloud organizations list\n ```\n\n The command output looks like the following example: \n\n ```\n DISPLAY NAME ID\n example-organization 29252605212\n ```\n2. Create a JSON file that defines your policy. The following example JSON\n file defines a policy that prevents all VPC networks from\n using Dedicated Interconnect:\n\n ```\n {\n \"Constraint\": \"constraints/compute.restrictDedicatedInterconnectUsage\",\n \"listPolicy\": {\n \"allValues\": \"DENY\"\n }\n }\n ```\n3. Use the `gcloud` Resource Manager `set-policy` command to set the organization\n policy:\n\n ```\n gcloud resource-manager org-policies set-policy JSON_FILE_NAME\n --organization=ORGANIZATION_ID\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eJSON_FILE_NAME\u003c/var\u003e: the name of the JSON file that you\n created in the previous step, such as `policy-name.json`\n\n - \u003cvar translate=\"no\"\u003eORGANIZATION_ID\u003c/var\u003e: the ID of the organization that you\n previously found\n\nSet a policy at the organization, folder, or project level\n----------------------------------------------------------\n\nThe previous sections describe how to deny a specific VPC network\nor all VPC networks. You can also use the syntax described in\n[List constraints](/resource-manager/docs/organization-policy/understanding-constraints#list_constraint)\nto allow or deny VPC networks at the organization, project, or\nfolder level.\n\nWhat's next\n-----------\n\n- To learn more about Cloud Interconnect options, see the\n [Cloud Interconnect overview](/network-connectivity/docs/interconnect/concepts/overview).\n\n- To help you solve common issues that you might encounter when using\n Cloud Interconnect, see\n [Troubleshooting](/network-connectivity/docs/interconnect/support/troubleshooting)."]]