GCP:How to remove a lien from Google Cloud project?

Published on:
Last updated:

This post is also available in: 日本語 (Japanese)

When I trying to delete a project on Google Cloud Platform, the following message appears and unable to delete it.
I've written this note on what to do if you encounter this issue.
There are various cases and outdated information on the website, but in my case, I was able to delete it by following the steps below.

Project "YourProjectName" contains one or more liens to prevent accidental deletion. To delete the project, please remove the liens and try again.

Open the Cloud Shell on Google Cloud Platform

When deleting liens for multiple projects, if you try to delete them consecutively while the shell stay open, you will be unable to delete them due to permission issues. Therefore, I reopened Cloud Shell for each project.

Setting the Project ID in Cloud Shell

Run the following command. YourProjectId is the ID displayed in the project list.
Specify the project ID you want to delete.

gcloud config set project YourProjectId

Listing the liens in Cloud Shell

To display a list of liens for the project you want to delete, run the following command.

gcloud alpha resource-manager liens list

Deleting the lien in Cloud Shell

To delete the lien for the project you want to delete, run the following command using the lien name you want to delete (referred to as "Name" in Cloud Shell. In the example below, it's "YourLienName") displayed in the previous step.
If the lien is successfully deleted, you will see the message like "Deleted [liens/YourLienName]."

gcloud alpha resource-manager liens delete YourLienName

Delete the project in the Google Cloud Platform UI

In my case, after deleting the lien in Cloud Shell, and if there were no other issues, I was able to delete the project in the Google Cloud Platform UI.

No tags for this post.

About
Kuniyoshi Takemoto is the founder of Amelt.net LLC, and editor of this blog(www.amelt.net).Learn more and follow me on LinkedIn.