Deprovision Shared VPC
This page describes how to deprovision an existing Shared VPC configuration,disconnecting all service projects from a Shared VPC host project.Deprovisioning is a one-way process. Make sure that you are familiar with theShared VPC andProvision Shared VPC pages first.
Note: Shared VPC is also referred to as "XPN" in the API and command-lineinterface.Caution: Deleting a Shared VPC host project without following the processesdescribed here will cause an outage for instances in all service projectsattached to the host project. The directions for provisioning a Shared VPCexplain how tocreate an organization-level policy to limit IAM principals who canremove the lien that prevents deletion of hostprojects. If you have that policy inplace, then you limit the risk of deleting a host project without properlydeprovisioning it.Service Project Admin tasks
In each service project attached to the Shared VPC host project, aServiceProject Admin must remove all dependencieson the host project. Dependencies might include instances, instance groups,instance templates, backend services, and forwarding rules.
Determine affected resources
To identify resources that depend on the Shared VPC host project, aService Project Admin canlist its sharedsubnets. When theservice project is detached from the host project, these subnets will no longerbe available to it; thus, any resources that depend on them will be affected.
Delete resources
Once a Service Project Admin has identified the resources that will be affectedby the deprovisioning process, those resources will need to be deleted:
Deleteinstancesthat use subnets in the host project.
Deletemanaged instancegroups andunmanaged instancegroupsthat use subnets in the host project.
Delete instancetemplateswhose definitions depend on the host project.
Deleteinternal forwarding rules for internal TCP/UDP loadbalancers that reference asubnet in a Shared VPC network of the host project.
Delete static internal IP addresses used bynetworkinterfaces from VMs in othernetworks.
To do this, you must first get alistof the reserved addresses, thendeletethem.
Load Balancer Admin tasks
Note: This section only covers tasks that relate tointernal Application Load Balancers and regional external Application Load Balancers.Internal Application Load Balancers and regional external Application Load Balancers allow you to configurethe load balancer so that a URL map in one host or service project can referencebackend services (and backends) located across multiple projects inShared VPC environments.
Before you can delete a service project, you must make sure that any suchcross-project references to backend services in your service project have beenremoved. Load Balancer Admins will need to modify their URL maps to removereferences to backend services in your service project.
Shared VPC Admin tasks
All tasks in this section must be performed by aShared VPCAdmin.
Detach service projects
Repeat these steps for each service project you need to detach from theShared VPC host project.
Caution: Detaching a service project can only be done after the Service ProjectAdmins have deleted all service project resources that depend on the host project.Before performing these steps, make sure that Service Project Admins have completedService Project Admin tasks.Console
To view the Shared VPC page in the Google Cloud console, you must havethe Shared VPC Admin role.
- Go to theShared VPC page in the Google Cloud console.
Go to Shared VPC - Log in as a Shared VPC Admin.
- Select the host project you are removing service projects from.
- Click theAttached projects tab.
- Select the service project that you want to detach.
- Click theDetach Projects button.
- Review the information in the dialog.
- ClickDetach.
gcloud
If you have not already, authenticate to
gcloudas a Shared VPC Admin.ReplaceSHARED_VPC_ADMIN with the name of the Shared VPCAdmin:gcloud auth loginSHARED_VPC_ADMIN
Detach the service project from the host project. ReplaceSERVICE_PROJECT_ID with the project ID for the service projectandHOST_PROJECT_ID with the project ID for the host project.
gcloud compute shared-vpc associated-projects removeSERVICE_PROJECT_ID --host-projectHOST_PROJECT_ID
Confirm that the service project has been detached using one of thesecommands:
gcloud compute shared-vpc get-host-projectSERVICE_PROJECT_ID
gcloud compute shared-vpc list-associated-resourcesHOST_PROJECT_ID
If you only needed to detach service projects, log out of
gcloudtoprotect your Shared VPC Admin account credentials. Otherwise, skip thisstep and proceed withdisable the hostproject.gcloud auth revokeSHARED_VPC_ADMIN
API
Detach the service project.
POST https://compute.googleapis.com/compute/v1/projects/HOST_PROJECT_ID/disableXpnResource{ "xpnResource": { "id": "SERVICE_PROJECT_ID" }}Replace the placeholders with valid values:
- HOST_PROJECT_ID is the ID of the host project.
- SERVICE_PROJECT_ID is the ID of the service project todetach.
For more information, refer to the
projects.disableXpnResourcemethod.Confirm that the service project has been detached.
Check that the service project isn't attached to any host project.
GET https://compute.googleapis.com/compute/v1/projects/SERVICE_PROJECT_ID/getXpnHost
ReplaceSERVICE_PROJECT_ID with the ID of the serviceproject.
For more information, refer to the
projects.getXpnHostmethod.List the service projects attached the Shared VPC host project toconfirm that the project is no longer listed.
GET https://compute.googleapis.com/compute/v1/projects/HOST_PROJECT_ID/getXpnResources
ReplaceHOST_PROJECT_ID with the ID of the host project.
For more information, refer to the
projects.getXpnResourcesmethod.
Disable host project
Disabling Shared VPC for the host project is only possible after all serviceprojects have beendetached. When disabled, the lienthat prevents it from being easily deleted is removed automatically.
Console
To view the Shared VPC page in the Google Cloud console, you must havethe Shared VPC Admin role.
- Go to theShared VPC page in the Google Cloud console.
Go to Shared VPC - Log in as a Shared VPC Admin.
- Select the Host Project you want to disable.
- Click theDisable Shared VPC button.
- In the dialog, read the description carefully.
- Enter the project ID of the host project forHost project ID.
- ClickDisable.
gcloud
If you have not already, authenticate to
gcloudas a Shared VPC Admin.ReplaceSHARED_VPC_ADMIN with the name of the Shared VPCAdmin:gcloud auth loginSHARED_VPC_ADMIN
Disable Shared VPC for the host project. ReplaceHOST_PROJECT_ID with the ID of the host project.
gcloud compute shared-vpc disableHOST_PROJECT_ID
Confirm that the project is no longer listed as a host project for yourorganization. ReplaceORG_ID with your organization ID(determined by
gcloud organizations list).gcloud compute shared-vpc organizations list-host-projectsORG_ID
If you only needed to disable a host project, you can log out of
gcloudto protect your Shared VPC Admin account credentials.Otherwise, skip this step and continue withdeleteprojects.gcloud auth revokeSHARED_VPC_ADMIN
API
Disable Shared VPC for the project.
POST https://compute.googleapis.com/compute/v1/projects/HOST_PROJECT_ID/disableXpnHost
ReplaceHOST_PROJECT_ID with the ID of the host project.
For more information, refer to the
projects.disableXpnHostmethod.List your host projects to confirm that the project isn't listed.
POST https://compute.googleapis.com/compute/v1/projects/HOST_PROJECT_ID/listXpnHosts
ReplaceHOST_PROJECT_ID with the ID of the host project.
For more information, refer to the
projects.listXpnHostsmethod.
Delete projects
This section discusses deleting projects that are no longer used; for example,you may have service projects that need to be deleted after they have beendetached from a host project, or you may no longer need the host projectafter it has been disabled.
Delete host project
You may choose to keep it as a normal project orshut itdown.Shutting down a project deletes it.
An IAM principal can delete the host project if the principal has theresourcemanager.projectDeleterrole for yourorganization or if the principal is the owner of the host project.Shared VPC Admins may be able to delete host projects if they have thecorrect role or ownership.
Delete service project
You may choose toshut down each serviceprojectif you no longer need them. Before doing so, make sure thatthe service projecthas been detached from the host project.
An IAM principal can delete a service project if the principal has theresourcemanager.projectDeleterrole for yourorganization or if the principal is the owner of the service project. ServiceProject Admins may be able to delete service projects if they have the correctrole or ownership.
Forcibly delete a host project
While Shared VPC is active for a host project, a lien is placed on the projectto prevent it from being accidentally deleted. Because this lien can be removedby a project owner, theguidelines for provisioning a SharedVPC include steps to define anorganizational policy that limits which IAM principals have the ability toremove a project lien.
Normally, a host project should be deletedafter the following tasks have beencompleted in this order:
When Shared VPC has been disabled, the lien that protects the host project isautomatically removed.
This section details how to forcibly shut down a host project. You should onlyconsider this option under these circumstances:
- You cannot follow the normal steps of detaching service projects and disablingShared VPC.
- There are additional liens protecting the host project beyond the one that isadded automatically.
If you forcibly shut down a host project and you have resources in serviceprojects that use the Shared VPC network, the following events occur:
- All Shared VPC networks, their subnets, routes, firewall rules, and allnetworking resources in the host project are deleted.
- Resources, such as running instances in the service projects attached to thehost project, are stopped.
- Internal TCP/UDP load balancers are disabled if their forwarding rules dependon the Shared VPC network.
gcloud
Authenticate to
gcloudas an IAM principal who can remove a projectlien. If you havean organizational policy that limits which principalscan remove liens, you mustauthenticate as an IAM principal with theresourcemanager.lienModifierrole for your organization. If you do not have such a policy in place,the project owner for the host project can remove the lien.ReplaceACCOUNT with the name of the appropriate IAMprincipal:
gcloud auth loginACCOUNT
List the liens associated with the host project. ReplaceHOST_PROJECT_ID with the ID of the host project.
gcloud alpha resource-manager liens list \--projectHOST_PROJECT_ID
Remove each lien by name, one at a time, until no more liens are present.ReplaceLIEN_NAME with the name of the lien to remove.
gcloud alpha resource-manager liens deleteLIEN_NAME \--projectHOST_PROJECT_ID
Confirm that all liens have been removed.
gcloud alpha resource-manager liens list \--projectHOST_PROJECT_ID
After removing the lien, you can log out of
gcloudto protect thecredentials of the IAM principal which has permission to remove liens.gcloud auth revokeACCOUNT
The host project can now beshutdown.
API
List the liens that are associated with the host project.
GET https://cloudresourcemanager.googleapis.com/v1/liens?parent=projects:HOST_PROJECT_ID
ReplaceHOST_PROJECT_ID with the ID of the host project.
For more information, refer to the
liens.listmethod.Remove each lien by name until no more liens are present.
DELETE https://cloudresourcemanager.googleapis.com/v1/liens/LIEN_NAME
ReplaceLIEN_NAME with the name of the lien to delete.
For more information, refer to the
liens.deletemethod.List the liens again to confirm that they have been removed.
What's next
- For more information about Shared VPC, seeShared VPC.
- For instructions about setting up Shared VPC, seeProvision Shared VPC.
- For instructions about setting up Google Kubernetes Engine clusters with Shared VPC,seeSet up clusters with Shared VPC.
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 2026-02-19 UTC.