sunbos

GCP Factory Reset

0
0
# Install this skill:
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

  1. Google Cloud SDK: Ensure gcloud is installed.
  2. Authentication: The user must be logged in to the target account.
    • Run gcloud auth login if not authenticated.
    • Run gcloud auth list to verify the active account.

๐Ÿš€ Workflow

Phase 1: Wipe Cloud Resources (Projects)

Only wiping projects ensures that all underlying resources (VMs, Storage, DBs) are destroyed.

  1. 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".
  2. 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.

  1. Check Status:

    • Run gcloud billing accounts list.
    • If OPEN is True, the account is active.
  2. 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.

  1. Revoke Credentials:
    • Run gcloud auth revoke --all.
  2. Clean Configurations:
    • Delete the gcloud config directory: rm -rf ~/.config/gcloud.
  3. Verify:
    • Run gcloud auth list. It should show no credentialed accounts.

โš ๏ธ 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.