This project provides an end-to-end, production-grade way to automatically generate a Google Cloud inventory with zero GCP cost, no static credentials, and no manual updates.
It is designed to be:
The result is a continuously updated Excel / CSV cloud inventory generated on a schedule.
On a fixed schedule (or manually), GitHub Actions:
inventory.xlsxinventory_projects.csvinventory_resources.csvinventory_apis.csvNo credentials are stored in the repository. No GCP services that generate cost are required.
GitHub Actions (cron / manual)
│
▼
Workload Identity Federation (OIDC)
│
▼
Service Account (read-only)
│
▼
Cloud Asset Inventory + Service Usage API
│
▼
Excel / CSV inventory (auto-commit)
Key properties:
You need:
This setup works without an Organization or Folder, but supports them if present.
This service account will be used only for inventory collection.
gcloud iam service-accounts create inventory-bot \
--project YOUR_PROJECT_ID \
--display-name "Cloud Inventory Bot"
Why this exists:
Because this setup does not rely on an Organization or Folder, permissions are granted per project.
| Role | Purpose |
|---|---|
roles/viewer |
Read access to project resources |
roles/cloudasset.viewer |
Access Cloud Asset Inventory |
roles/serviceusage.serviceUsageViewer |
List enabled APIs |
SA="serviceAccount:inventory-bot@YOUR_PROJECT_ID.iam.gserviceaccount.com"
for P in $(gcloud projects list --format="value(projectId)"); do
gcloud projects add-iam-policy-binding "$P" \
--member="$SA" \
--role="roles/viewer"
gcloud projects add-iam-policy-binding "$P" \
--member="$SA" \
--role="roles/cloudasset.viewer"
gcloud projects add-iam-policy-binding "$P" \
--member="$SA" \
--role="roles/serviceusage.serviceUsageViewer"
done
If you add new projects later, simply re-run this script.
github-poolgoogle.subject = assertion.sub
attribute.repository = assertion.repository
attribute.ref = assertion.ref
attribute.repository == "OWNER/REPOSITORY_NAME"
This ensures only the specified GitHub repository can authenticate.
gcloud iam service-accounts add-iam-policy-binding \
inventory-bot@YOUR_PROJECT_ID.iam.gserviceaccount.com \
--project YOUR_PROJECT_ID \
--role roles/iam.workloadIdentityUser \
--member "principalSet://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/github-pool/attribute.repository/OWNER/REPOSITORY_NAME"
gcloud iam service-accounts add-iam-policy-binding \
inventory-bot@YOUR_PROJECT_ID.iam.gserviceaccount.com \
--project YOUR_PROJECT_ID \
--role roles/iam.serviceAccountTokenCreator \
--member "principalSet://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/github-pool/attribute.repository/OWNER/REPOSITORY_NAME"
Both bindings are required.
In your GitHub repository:
Settings → Secrets and variables → Actions → Secrets
| Name | Value |
|---|---|
GCP_WORKLOAD_IDENTITY_PROVIDER |
projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/github-pool/providers/PROVIDER_NAME |
GCP_SERVICE_ACCOUNT |
inventory-bot@YOUR_PROJECT_ID.iam.gserviceaccount.com |
No credentials or tokens are committed to the repository.
.github/workflows/cloud-inventory.yml.example
inventory/
export_inventory.py
projects.txt
requirements.txt
inventory.xlsx (generated)
The
.exampleworkflow does not run automatically. Rename it tocloud-inventory.ymlto enable execution.
This file explicitly defines which projects are inventoried:
project-a
project-b
project-c
This avoids relying on global project listing permissions and keeps scope explicit.
The Python script:
projects.txt--asset-typesImportant implementation detail:
--asset-types, not query filtersKey properties:
id-token: write and contents: writeSchedule:
cron: "0 6 * * *"
Runs daily at 06:00 UTC.
You get:
This setup scales well from small personal projects to professional environments.
MIT License
Copyright (c) 2026 Paolo Ronco
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.