Troubleshooting project deletion

The following sections describe common errors that can block the deletion of a project, and what you can do to resolve them. If you are having issues, try using the Google Cloud CLI to shut down a project, and note any error message you receive.

Liens

If there is a lien on a project, that project cannot be deleted until the lien is removed. If you have the resourcemanager.projects.get permission on the project, you can list the liens applied to a project with the liens list gcloud CLI command.

For more information about liens, see protecting projects with liens.

Cloud Endpoints

Cloud Endpoints are special resources that are considered child resources under a project. This can block the deletion of a project where Endpoints exist.

The following example shows an attempt to delete a project using the Google Cloud CLI failing due to the existence of Endpoints under the project:

@cloudshell:~ ($project)$ gcloud projects delete $project
Your project will be deleted.

Do you want to continue (Y/n)?  Y

ERROR: (gcloud.projects.delete) FAILED_PRECONDITION: active child resource
- '@type':type.googleapis.com/google.rpc.PreconditionFailure
 violations:
 - description: active child resource
   subject: services/$service
- '@type':type.googleapis.com/google.rpc.ResourceInfo
 resourceName: projects/$project
 resourceType: PROJECT

To resolve this issue, delete the Endpoints before you attempt to delete the project.

For more information about Endpoints, see the Cloud Endpoints documentation.

Management projects

If a project is designated as a management project for an app-enabled folder, you can't delete the project directly. This can block the deletion of a project with an error message similar to the following:

ERROR: (gcloud.projects.delete) FAILED_PRECONDITION: Deletion is not allowed
because this project is the management project for the folder it resides in.

To resolve this issue, you can disable application management on the parent folder. Disabling application management automatically deletes the management project.

To disable application management using the gcloud CLI, run the following command:

gcloud resource-manager capabilities update folders/FOLDER_ID/capabilities/app-management --no-enable

For instructions on disabling application management using the Google Cloud console, see Managing applications in a folder.

Workaround for orphaned states

In some cases, a parent folder's application management might appear to be disabled, but the associated project remains blocked with the same error. To unlink the project from the folder in this scenario, you can clear the App Hub boundary CRM node.

To clear the boundary using the gcloud CLI, run the following command:

gcloud alpha apphub boundary update --project=PROJECT_ID --location=global --crm-node=''

Shared Virtual Private Cloud

If a project has shared Virtual Private Cloud (VPC) enabled or has service projects attached, a lien will block the deletion of the project.

For more details and instructions on how to detach service projects and disable shared VPC, see Deprovisioning shared VPC.