GCP Collector

GCP Collector


Have you ever found yourself faced with the daunting task of conducting an inventory of resources within your GCP project? We understand the challenges that come with this time-consuming and error-prone process. Whether you're dealing with just a couple of projects or juggling a multitude of them, the struggle remains the same.

But fear not! Introducing GoogleResourceInventory, or GRI for short (https://github.com/rafaeldomi/GoogleResourceInventory) — your ultimate solution to effortlessly tackle this inventory challenge. This project is designed to simplify the resource collection process by seamlessly extracting and organizing information from your projects, saving them to convenient file formats such as CSV, JSON, and XLSX. You'll find more detailed information on the available options in the project's README.

In short words: Its a python program that collects information from the project and save to CSV, json and xlsx, just choose the output you would like. You can read more about the options in the README of the project.

To get started, all you need to do is clone the repository and install the necessary requirements:

$ git clone https://github.com/rafaeldomi/GoogleResourceInventory.git
$ pip3 install -r requirements

Once set up, running the GRI is as simple as executing the following command (ancient-small-323301 was my logged project in gcloud at the moment, a project just for this demonstration):

$ ./collect.py
** Processing project: ancient-small-323301 **
PRJ: ancient-small-323301 - Networks
PRJ: ancient-small-323301 - DeploymentManager
PRJ: ancient-small-323301 - Compute Machines
Reading: 1/1 Zone: zones/us-central1-a Name: rabbitmq-25-03-2020-1-vm
PRJ: ancient-small-323301 - CloudSQL
PRJ: ancient-small-323301 - Functions
PRJ: ancient-small-323301 - GCS
PRJ: ancient-small-323301 - GKE
PRJ: ancient-small-323301 - Artifact Registry
PRJ: ancient-small-323301 - PubSub
Saving to output
 | - Saving network
 | - Saving net_peer
 | - Saving net_vpn
 | - Saving compute
 | - Saving cloudsql
 | - Saving functions
 | - Saving gcs
 | - Saving gke
 | - Saving artifact
 | - Saving pubsub
 | - Saving deployments
 | - Saving projects
Finished

With just one command, the GRI will diligently scour your project, capturing essential resource details and generating output files neatly organized in the 'output' folder.

$ ls  output/
output_artifact.csv  output_compute.csv      output_functions.csv  output_gke.csv       output_net_vpn.csv  output_projects.csv
output_cloudsql.csv  output_deployments.csv  output_gcs.csv        output_net_peer.csv  output_network.csv  output_pubsub.csv

But wait, it gets even better! You can export the collected data to multiple formats simultaneously. For example, to generate both XLSX and JSON outputs, execute:

./collect.py -o xls -o json

When exporting to Excel, the GRI creates an 'output.xlsx' file within the 'output' folder, with each resource allocated its own individual tab, ensuring easy navigation and organization.

db84427990f10d2f74b7df05551fcc003b8ad7319db9c02efaa01e41cf54084d.png

Image 1: Example of a output in the spreadsheet.

What about managing multiple projects? No problem! By creating a file listing the projects you wish to include (one project per line), you can instruct the collector to utilize this custom project list. For example:

cat list.projects
project-id1
project-id2
./collect.py -m list.projects

Note: 'list.projects' is just a recommended filename; feel free to use any name you prefer.

We hope that GoogleResourceInventory proves to be a valuable asset on your journey, and we encourage you to contribute to the project if you find it useful. Remember to check out the Everything One Technology blog for more insightful posts that can further enhance your experiences.

Thank you for joining us on this adventure, and we look forward to seeing you on the next page.

- Blogpost created without using AI tools -

How do you rate this article?

4



Everything One Technology
Everything One Technology

Here in Everything One technology you will find information about Clouds, kubernetes, database (mostly postgres) and more. Save us and keep reading. Thank You, and see you in the next page.

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.