4
4
Table of Contents

If you're managing costs on Google Cloud Platform (GCP), you already know that Committed Use Discounts (CUDs) are one of the most effective ways to reduce your cloud bill. By committing to a one- or three-year usage plan, you get heavily discounted rates compared to pay-as-you-go pricing.

But here’s the kicker: while you can view CUD data in the GCP Console, you can’t access it via BigQuery billing export, which is where most teams do their reporting and automation. That means this vital information is trapped in the UI, disconnected from your dashboards, pipelines, or alerting systems.

While working on cost optimization at CloudKeeper, I ran into this exact limitation. We were building our CloudKeeper Lens to unify all GCP billing data — usage, service-level costs, and commitment data — in one place. But we quickly hit a wall: there’s no API, no export, no CLI tool to fetch CUD details. Only a browser.

So, I decided to build my own automation. In this post, I’ll share exactly how I solved this problem — using Python, Selenium, and some practical engineering — and how it now helps both my team and our clients get better visibility into their cloud spend.

The Problem: CUD Data Is Trapped in the Console

Google’s billing export to BigQuery provides an excellent foundation for cloud cost analysis. But it’s incomplete, especially when it comes to commitments. The export is missing:

  • Which commitments are active or expiring?
  • What services and SKUs are covered?
  • How well they’re being utilized.
  • Which projects are benefiting from them?

Without this data, it’s almost impossible to build alerts for expiring discounts, compare committed vs actual usage, or create a transparent cost model across engineering and finance.

My Approach: Automating GCP CUD Reports with Selenium

  1. Secure Login
    The script securely logs into the GCP Billing Console with multi-factor authentication support. It can handle verification codes and recovery steps if required, using secure storage for credentials.
  2. Identify Billing Accounts
    It fetches a list of billing accounts associated with the user or service account and filters out irrelevant ones, ensuring that we extract CUD data for every valid account.
  3. Navigate and Download Reports
    For each billing account, the script opens the Committed Use Discounts page and downloads two types of reports:
  • Flat List Report – Detailed view by SKU and project
  • Grouped List Report – Aggregated view of active commitments
  1. Store and Distribute the Data
    The downloaded reports are automatically:
  • Uploaded to a central cloud storage bucket
  • Shared with finance or platform teams via email or Slack
  • Optionally pushed to internal dashboards or data pipelines
  1. Enable Alerts and Monitoring
    Once we had the data, we built custom alerts on:
  • Commitment expirations (e.g., notify 30 days before)
  • Under-utilized commitments
  • Missed savings opportunities

These alerts help teams take timely action — whether that means renewing commitments, shifting workloads, or re-evaluating spend.

Code Walkthrough: Automating GCP CUD Report Extraction

Here's a look at the core components of the Python script I built to automate the retrieval of GCP Committed Use Discount (CUD) reports. This script logs in with MFA, downloads CSV reports, and uploads them to GCS while emailing them to stakeholders.

1 - Initial Selenium Setup

Initial Selenium setup scriptInitial Selenium setup script

2- Login with MFA and Recovery Email

MFA Login and Recovery mail MFA setup with recovery mail

3 - Fetching Billing Account IDs

Function to fetch billing account details

4 - Downloading CUD Reports

Script to download CUD reportsScript to download CUD report

5 - Uploading to Google Cloud Storage

Script to upload to Google Cloud Storage

6 - Sending the Reports via Email

Script to send Google CUR report via Gmail

7 - Main Function

Driver function

The Outcome: Visibility, Control, and Optimization

This automation has unlocked previously inaccessible data, transforming it into a central asset for cost governance.

Teams now have real-time insight into how well CUDs are performing. Finance and engineering share a unified view, which helps in planning and accountability. We’ve already optimized spend by renewing the right commitments and reallocating underutilized ones.

In short, we’ve gone from guesswork to clarity — and we’ve done it without waiting for Google to fill in the gaps.

Why This Matters to Every Cloud Team

This isn’t just a technical workaround — it’s a strategic enabler. If your team is using CUDs, you owe it to yourself to track them properly. And unless you have this data in your reporting and monitoring workflows, you're flying blind.

Automation puts you back in control. It ensures your cloud discounts are being used as intended and helps you avoid surprises at renewal time.

Final Thoughts: Until GCP Adds an API, We Built Our Own Bridge

It’s entirely possible that Google Cloud will one day expose CUD data via an API or include it in billing exports. But until then, browser automation gives us what we need: visibility, control, and the ability to act.

At CloudKeeper, we’ve implemented this internally and helped clients do the same as part of broader cost optimization efforts. If you’re struggling with CUD visibility, feel free to reach out — we’re happy to share what we’ve learned.

12
Let's discuss your cloud challenges and see how CloudKeeper can solve them all!
Meet the Author
  • Manav
    DevOps Engineer

    Manav specializing in Google Cloud Platform (GCP) with expertise in designing and implementing automation solutions to optimize and streamline cloud operations.

Leave a Comment

Speak with our advisors to learn how you can take control of your Cloud Cost