GCP
Connect Google Cloud Platform billing to StackSpend via BigQuery export.
What StackSpend tracks
StackSpend imports GCP costs through the BigQuery billing export. This provides project-level, service-level, and dataset-level granularity. Data is updated on a daily batch schedule with a 24–48 hour latency after it lands in BigQuery.
Data reference
| Property | Value |
|---|---|
| Latency | 24–48 hours |
| Historical data | From export-enable date only |
| Setup time | ~10 min |
Prerequisites
- A GCP project with an active billing account
- Cloud Billing API enabled
- BigQuery API enabled
This is the most complex provider setup (~10 minutes) because it requires enabling BigQuery billing export, creating a service account, and granting three separate IAM roles.
Setup
Enable BigQuery billing export
Go to GCP Console → Billing → Billing export → BigQuery export → Edit settings.
- Select your project.
- Create a new dataset or choose an existing one. Note the dataset ID — you will need it later.
- Enable Standard usage cost export.
- Click Save.
Data takes 24–48 hours to start appearing after enabling export for the first time.
Enable the Cloud Billing API
Go to Console → APIs & Services → Enable APIs & Services. Search for Cloud Billing API and click Enable.
Create a service account
Go to Console → IAM & Admin → Service Accounts → Create service account.
- Set the name to
stackspend-billing. - Click Create and continue, then Done.
Grant IAM roles
The service account needs three roles granted at different levels.
(a) Billing Account Viewer — on the billing account
Go to Billing → Account management → Roles → Add principal. Paste the service account email and assign Billing Account Viewer. This must be set on the billing account, not the project.
(b) BigQuery Job User — on the project
Go to IAM → Add principal. Paste the service account email and assign BigQuery Job User.
(c) BigQuery Data Viewer — on the dataset
Open BigQuery Studio, navigate to your billing dataset, click Share → Add principal, paste the service account email, and assign BigQuery Data Viewer.
Create a JSON key
Go to Service Accounts → your service account → Keys → Add Key → Create new key. Select JSON and download the key file. Keep this file secure.
Note your IDs
Collect the following before proceeding:
- Billing Account ID — Billing → Account management, shown at the top of the page.
- Project ID — visible in the project selector dropdown.
- Dataset ID — the dataset you selected or created in Step 1.
- Table ID — usually named
gcp_billing_export_v1_..., visible in BigQuery Studio under your dataset.
Add to StackSpend
Go to Providers → Add provider → GCP. You will need all four IDs from Step 6.
Add GCP provider
Paste the entire contents of the JSON key file you downloaded.
Verify
If you just enabled billing export, wait 24–48 hours before expecting data to appear. Check the provider page in StackSpend for the last sync status and any errors.
Frequently asked questions
What GCP access does StackSpend need?
StackSpend needs a read-only service account that can read the BigQuery billing export, which gives cost breakdowns by project, service, and SKU. The account is granted Billing Account Viewer, BigQuery Job User, and BigQuery Data Viewer — all read-only roles.
Is the GCP connection read-only?
Yes, StackSpend only reads from the BigQuery billing export and never writes to your GCP environment. The three IAM roles it uses are all viewer-level permissions scoped to billing data.
How long does GCP setup take?
Setup takes about 10 minutes because it requires enabling BigQuery billing export, creating a service account, and granting three separate IAM roles. It is the most involved provider setup, so write down your Billing Account ID, Project ID, Dataset ID, and Table ID before you start.
Why don't I see cost data yet?
GCP billing data takes 24–48 hours to start appearing after you first enable BigQuery billing export. GCP has no historical backfill, so StackSpend can only import costs from the date export was enabled — enable it as early as possible.