Protect from Delete GCP project

gcloud projects delete one-click-tbd
Your project will be deleted.
Do you want to continue (Y/n)? YDeleted [https://cloudresourcemanager.googleapis.com/v1/projects/one-click-tbd].You can undo this operation for a limited period by running the command below.
$ gcloud projects undelete one-click-tbd
See https://cloud.google.com/resource-manager/docs/creating-managing-projects for information on shutting down projects.
gcloud alpha resource-manager liens create \
--restrictions=resourcemanager.projects.delete \
--reason="Super important production system"
Check that is applied:
gcloud alpha resource-manager liens list
NAME ORIGIN REASON
p151505267786-la6de8a11-573d-4724-8219-ed5a8669d2d2 user@companydomain.com Super important production system
gcloud projects delete one-click-not-tobedeleted 
Your project will be deleted.
Do you want to continue (Y/n)? YERROR: (gcloud.projects.delete) FAILED_PRECONDITION: Precondition check failed.
- '@type': type.googleapis.com/google.rpc.PreconditionFailure
violations:
- description: A lien to prevent deletion was placed on the project by [xpn.googleapis.com].
Remove the lien to allow deletion.
subject: liens/p151505267786-la6de8a11-573d-4724-8219-ed5a8669d2d2
type: LIEN
- '@type': type.googleapis.com/google.rpc.Help
links:
- description: Troubleshooting project deletion
url: https://cloud.google.com/resource-manager/docs/troubleshooting-project-deletion
- '@type': type.googleapis.com/google.rpc.ErrorInfo
domain: cloudresourcemanager.googleapis.com
reason: PROJECT_DELETE_LIEN

--

--

--

Working as Cloud Architect & Software enthusiastic

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

2020: Year in Review | Intrinio

The Advantages of Python Programming Language

Writing a Firebase Clone with PostgreSQL and Node.js (Part I)

RBHC — Recursive Binary Hierarchical Clustering

RBHC logo

Creating the Swing Indicator in TradingView — The Full Guide

What I learned from building my second quadcopter — an in depth breakdown of PID controllers

Debugging Tutorial 1 — Introduction: Conditional Breakpoints

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
NIRAV SHAH

NIRAV SHAH

Working as Cloud Architect & Software enthusiastic

More from Medium

Cara Set Up Network dan HTTP Load Balancers di GCP

Cara Set Up Network dan HTTP Load Balancers di GCP

Image Vulnerability Detection using Trivy

How to detect face masks using cloud service?

How to Create GCP Image using GCLOUD Command