0

I'm looking to fetch cost usage reports for all my GCP projects using the google-cloud-billing library in Python. To achieve this, I've created a Service Account. However, I encountered an issue while trying to attach the "Billing Account Viewer" role to my service account – it doesn't seem to be available.

I realized that I might have created this service account at the project level. Is this the correct approach, or should I have created it at a different level?

Also, if my goal is to utilize the google-cloud-billing library to retrieve cost report details for all projects, could you provide guidance on how to properly configure the service account for this purpose?

Thank you for your assistance!

ArunKumar
  • 179
  • 1
  • 1
  • 11
  • You must grant permission to the service account at the billing account. However, there is no API to fetch billing data. The API you are trying to use is a resource/service management API. You must export billing data to BigQuery and then query BigQuery. – John Hanley Aug 11 '23 at 15:42
  • Up to now, it's not possible to get the cost as you see it on the UI. There are a lot of customer requests for that but for now, it's the @JohnHanley solution: export billing data to BigQuery and query BigQuery – guillaume blaquiere Aug 12 '23 at 08:21
  • Hi @JohnHanley I've attempted to export the billing data to BigQuery, but unfortunately, I'm not able to find the "billing export" option. Just to clarify, I do have owner permissions for the project. If you have any insights or suggestions on resolving this? – ArunKumar Aug 17 '23 at 02:27
  • 1
    Go to Billing. You must be a Billing Account Administrator or Billing Account Costs Manager. Then follow this link: https://cloud.google.com/billing/docs/how-to/export-data-bigquery – John Hanley Aug 17 '23 at 03:52

0 Answers0