Implement GitOps workflows with ArgoCD and Flux for automated, declarative Kubernetes...
npx skills add sunbos/sunbo-skills --skill "GCP Factory Reset"
Install specific skill from multi-skill repository
# Description
Automates the process of factory resetting a Google Cloud Platform account by deleting all projects, closing billing accounts, and cleaning up local credentials.
# SKILL.md
name: GCP Factory Reset
description: Automates the process of factory resetting a Google Cloud Platform account by deleting all projects, closing billing accounts, and cleaning up local credentials.
author: sunbos
version: 1.0.0
GCP Factory Reset Skill
This skill helps the user completely reset their Google Cloud Platform (GCP) account to a "fresh" state. It handles the deletion of all cloud projects, verification of billing account closure, and removal of local authentication credentials.
🛠 Prerequisites
- Google Cloud SDK: Ensure
gcloudis installed. - Authentication: The user must be logged in to the target account.
- Run
gcloud auth loginif not authenticated. - Run
gcloud auth listto verify the active account.
- Run
🚀 Workflow
Phase 1: Wipe Cloud Resources (Projects)
Only wiping projects ensures that all underlying resources (VMs, Storage, DBs) are destroyed.
-
Execute the Cleanup Script:
- The skill relies on a Python script to iterate and delete projects.
- The skill relies on a Python script located at
${PLUGIN_DIR}/skills/gcp_factory_reset/scripts/clean_gcp.py. - Run the script:
python3 "${PLUGIN_DIR}/skills/gcp_factory_reset/scripts/clean_gcp.py".
-
Handle "Permission Denied":
- The script identifies projects that cannot be deleted (e.g., Shared projects, Sandbox projects).
- Action: Inform the user about these projects. Suggest they leave the project via the GCP Console if necessary.
Phase 2: Close Billing Accounts
Note: GCP API/CLI does NOT support closing billing accounts programmatically. This must be done manually.
-
Check Status:
- Run
gcloud billing accounts list. - If
OPENisTrue, the account is active.
- Run
-
Manual Intervention:
- If billing is active, guide the user to the Billing Console.
- Instruct them to:
Account Management->Close Billing Account.
Phase 3: Local Environment "Sanitization"
This is the final step to remove all traces from the local machine.
- Revoke Credentials:
- Run
gcloud auth revoke --all.
- Run
- Clean Configurations:
- Delete the gcloud config directory:
rm -rf ~/.config/gcloud.
- Delete the gcloud config directory:
- Verify:
- Run
gcloud auth list. It should show no credentialed accounts.
- Run
⚠️ Safety Warnings
- Irreversible: Project deletion is (mostly) irreversible after the 30-day soft-delete period. Billing closure stops services immediately.
- Data Loss: Ensure the user has backed up any critical data before proceeding.
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.