SuperAPI AI Directory

gcp-project-cleanup

Deployment & operations

View repository

Updated 10-16 04:38

About this skill

GCP Project Cleanup

Take inventory of and organize Google Cloud projects.

Prerequisites

  • The gcloud CLI is installed
  • gcloud auth login You are authenticated with

Safety Guidelines

Project deletion is an irreversible operation, and the project is permanently deleted after 30 days. To prevent accidental deletion, follow these steps:

  1. Do not run deletion commands during the investigation phase
  2. After completing the investigation of all projects, present the list to the user
  3. Do not delete until the user explicitly specifies the deletion targets
  4. Do not delete multiple projects at once. Confirm with the user one at a time

Workflow

Phase 1: Investigation (deletion commands prohibited)

1.1 Obtaining the project list

gcloud projects list --format="table(projectId,name,createTime.date('%Y-%m-%d'),lifecycleState)"

1.2 Checking resources for each project

For each project, check the following:

  • Enabled APIs
  • Running resources (Cloud Run, Compute Engine, Cloud Functions, etc.)
  • Storage
  • Billing status

For detailed commands, refer to references/gcloud-commands.md .

1.3 Checking IAM permissions

Deletion requires Owner permission. Deletion is not possible with Editor or lower.

gcloud projects get-iam-policy PROJECT_ID --format="table(bindings.role,bindings.members)"

1.4 Presenting the investigation results

After completing the investigation of all projects, present the list in the following format:

Project Creation date Resources present Permissions Deletable
example-1 2023-01 None Owner Yes
example-2 2024-06 Cloud Run running Owner Needs confirmation
example-3 2022-03 None Editor No

Ask the user for confirmation, such as "Which project do you want to delete?"

Phase 2: Deletion (only after user approval)

2.1 Project deletion

Only when the user has explicitly approved, execute one at a time:

gcloud projects delete PROJECT_ID --quiet

2.2 Checking the deletion result

gcloud projects describe PROJECT_ID --format="value(lifecycleState)"

Confirm that it is in the DELETE_REQUESTED state.

If restoration is needed (within 30 days):

gcloud projects undelete PROJECT_ID

Phase 3: IAM cleanup

3.1 Removing yourself from IAM

With Editor permission, you cannot remove yourself (the setIamPolicy permission is required).

Even if you have Owner permission, you cannot delete if you are the only Owner.

3.2 Requesting deletion from the Owner

If you cannot delete it yourself, ask the Owner.

Additional Information

  • Project deletion is not immediate; it enters the DELETE_REQUESTED state
  • It is permanently deleted after 30 days, and the project ID cannot be reused
  • Even if billing is disabled (billingEnabled: False), the project remains
  • gen-lang-client-* is a project automatically created by Google AI Studio