GCP Resource Inventory (GCPRI) is a simple utility for collecting an inventory of GCP resources across one or more scopes (projects, folders or organizations). It uses the Cloud Asset API to query all resources and outputs the results as JSON or CSV.
pip install gcpriTo install the latest code directly from this repository, clone the repo and run:
pip install -e .You must also ensure that the Cloud Asset API is enabled and that the
calling account has sufficient permissions (typically roles/viewer).
The script uses Application Default Credentials to call the Cloud
Asset API. You can authenticate by either setting the
GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of a
service account key file or by logging in with gcloud:
gcloud auth application-default loginVerify that the credentials work by listing resources with gcloud:
gcloud asset search-all-resources --scope="projects/PROJECT_ID" --limit=1python -m gcpri PROJECT_ID [ANOTHER_PROJECT] \
--folders FOLDER_ID [ANOTHER_FOLDER] \
--organizations ORG_ID [ANOTHER_ORG] \
--output inventory.jsonPass folder or organization IDs with the --folders and --organizations
flags. Each may be specified multiple times. Use --format csv to output a
CSV file instead of JSON. Pass --verbose to see informational logs during
execution.
This project is licensed under the MIT License.