How to extract cloud run details across all projects under a GCP Org
If you want to collect GCP cloud run details across all projects under your org , then this post is for you. Collecting the inventory details of all application service assets is an important task for all large enterprises. This discovery is often done via a tool which collects all the required asset information and stores them in a centralized config repository.
But if you don't want to spend money on any tool and rather rely on google APIs to extract these details, the below python code will be useful to you. In this code , I have tried to extract details of cloud run Images, their Namespace , CPU and Memory details. This can be re-purposed for collecting various GCP resource details, All you have to do is get the projects under an org, iterate through them, initialize the respective service client and extract the required details.
After you run this code , a csv file will be generated with the details on the cloud run assets.
Pre-requisites:
- Gcloud SDK — Authenticate into your account
- GCP Org level read access privileges
Python code:
Thanks for reading this post, I hope it was helpful to you.