This GitHub repository is dedicated to onboarding customers into Crayon's Google Cost Control platform. It provides detailed instructions for the steps customers need to take to onboard their Google Accounts to Crayon's Google Cost Control successfully. It details how to export Google Cloud billing and recommendation data to BigQuery for better cost management and analysis.
- Version: 1.0
- Authors: Crayon FinOps Team
- Company: Crayon
- Last Updated: 2024-12-13
- An active Google Cloud Billing Account.
- The Owner role for the project is required to enable APIs, create custom roles, datasets, and service accounts, as well as to configure permissions.
If you haven't enabled the Cloud Billing export to BigQuery, follow this link to configure the export. This setup will automatically export comprehensive Google Cloud billing information, including usage, cost estimates, and pricing data, to a specified BigQuery dataset throughout the day.
Choose the project where Cloud Billing export to BigQuery has been enabled. Ensure it is selected at the top of the Google Cloud Console.
Two custom roles are required: one for project-level permissions and another for BigQuery-level access. The project-level role tailors permissions to specific project needs, while the BigQuery-level role ensures precise access controls within the BigQuery environment.
-
Navigate to IAM & Admin > Roles in the Google Cloud Console.
-
Click + CREATE ROLE to create a new custom role.
-
Enter the following details:
-
Title:
Crayon FinOps GCP Project-Level Reader -
ID:
CrayonFinOpsGCPProjectLevelReader -
Description: Provide a meaningful description of the role.
-
Role launch stage: Set to "General Availability".
-
Click + ADD PERMISSIONS and add the following permissions:
-
Use the permissions filter or browse the list to select permissions to add to the role.
-
bigquery.readsessions.create -
bigquery.readsessions.getData -
bigquery.readsessions.update -
resourcemanager.projects.get -
bigquery.jobs.create
Continue selecting permissions. After selecting all five (5) permissions, click "ADD".
-
-
Click "SHOW ADDED AND REMOVED PERMISSIONS" (in red) to review and confirm the added permissions.
-
Click Create to finalize the role creation.
-
The BigQuery-level role ensures precise access controls for the BigQuery environment.
-
Repeat steps 2.1 (same steps as for the project-level role) to create a new role for BigQuery Level and use the following details:
- Title:
Crayon FinOps GCP Cost-and-Usage Reader - ID:
CrayonFinOpsGCPCostUsageReader - Description: Provide a meaningful description of the role.
- Role launch stage: Set to "General Availability".
- Title:
-
Add the following permissions:
bigquery.datasets.getbigquery.models.exportbigquery.models.getDatabigquery.models.getMetadatabigquery.models.listbigquery.routines.getbigquery.routines.listbigquery.tables.exportbigquery.tables.getbigquery.tables.getDatabigquery.tables.getIamPolicybigquery.tables.listbigquery.tables.replicateDataresourcemanager.projects.get
-
Create the role.
This section outlines the steps to create a service account, assign it a custom role, and generate an access key.
-
Verify that you are in the correct project at the top of the GCP console.
-
Navigate to IAM & Admin.
-
In the "IAM & Admin" section, click on "Service Accounts". Click the "CREATE SERVICE ACCOUNT" button at the top of the page.
-
Enter Service Account Details.
-
Assign a Role to the Service Account.
-
Click "CONTINUE" and then "DONE" to complete the service account creation.
-
Generating a Key for the Service Account.
After creating the service account, you will be directed to the service account details page.
-
Navigate to the "KEYS" tab.
-
Click "ADD KEY" and select "Create new key" from the dropdown menu.

-
Select the key type as JSON and click "CREATE" to generate the new key. A pop-up dialog box will prompt you to save the key file. Store the key file in a secure location and send it to Crayon using a secure method.

-
Verify Key Creation: The newly created key will appear in the "Keys" list with a status of "Active".

-
Ensure you are in the correct project by checking the project name at the top of the GCP console.
-
Navigate to BigQuery Studio
-
Locate the Cloud Billing Dataset
-
Assigning a Role
-
With the Cloud Billing dataset selected, click on "SHARING". and from the dropdown, select "Permissions".

-
Click the "ADD PRINCIPAL" button to start adding a new principal (e.g., a user or service account).

-
Enter the service account email created earlier, e.g.,
crayon-finops-gcp-cur@...iam.gserviceaccount.com. -
Click "Assign roles" to define the permissions for the service account.
-
Select the custom role you created earlier (e.g., "Crayon FinOps GCP Cost-and-Usage Reader") from the dropdown menu.

-
Click "SAVE" to apply the role to the service account for this dataset.

-
Review the list of permissions to confirm that the service account has been assigned the custom role, indicated by the presence of the service account's email and the custom role name in the permissions list as shown below:

-
-
Navigate to Enabled API & Services
-
Enable New API
-
In the "APIs & Services" dashboard, click the "+ENABLE APIS AND SERVICES" button to add new services.

-
In the API Library, use the search box to find the "Recommender API".

-
From the search results, select "Recommender API" to enable it.

-
On the "Product details" page for the Recommender API, confirm that the API is enabled for your project.
-
The status will show "API Enabled" with a checkmark. If it shows an "Enabled" button instead, click the button to enable the API.

-
-
Navigate to IAM & Admin > Manage Resources to access the page for managing projects and folders.

-
In the "Manage Resources" section, check the box next to the organization you want to manage.
-
Click the "ADD PRINCIPAL" button to add a service account for permission assignment.

-
In the "Grant access" dialog:
-
Enter the email of the service account created earlier (e.g.,
crayon-finops-gcp-cur@...iam.gserviceaccount.com) in the New Principals section. -
In the "Assign roles" section, assign the following roles:
-
Click "SAVE" to apply the new permissions to the service account.
-
Confirm that the service account is listed under the "Recommender Viewer", "Viewer", and "Recommender Exporter" roles in the updated list of permissions.

-
To use the BigQuery Data Transfer Service, ensure you have the Owner role for your project.
-
Enable BigQuery Data Transfer Service
-
Required Permissions
When setting up the data transfer, you will need specific permissions at both the project and organization levels. You can navigate to the roles in permissions as described in “Export Cloud Billing data to BigQuery” section above.-
Project-Level Permissions The following permissions are needed at the project level to set up the data transfer:
bigquery.transfers.update: Allows you to create the transfer.bigquery.datasets.update: Allows updates to the target dataset.resourcemanager.projects.update: Allows selection of a project to store the exported data.pubsub.topics.list: Allows selection of a Pub/Sub topic for notifications about your export.
-
Organization-Level Permissions
The following permission is required at the organization level for the export setup:recommender.resources.export: Export recommendations to BigQuery.
-
Additional Permissions for Cost Savings Recommendations
To export negotiated prices for cost savings recommendations:- Project-Level:
billing.resourceCosts.get: Allows exporting negotiated prices for project-level recommendations.
- Billing Account-Level:
billing.accounts.getSpendingInformation: Allows exporting negotiated prices for billing account-level recommendations.
- Project-Level:
-
-
Create a BigQuery Dataset to store data The dataset will use the same region selected during creation and cannot be changed later.
- Open the BigQuery Console, right-click your project name, and select Create Dataset.
- Follow the prompts to name and configure the dataset. For detailed guidance, refer to Creating and Managing Datasets in BigQuery.

-
Create a Data Transfer for Recommendations To set up a data transfer for exporting recommendations to BigQuery:
-
Open the Google Cloud Console and go to Recommendations Hub > BigQuery Export.

-
Select Destination Project and Enable BigQuery API
- Choose the project where the recommendation data should be stored
- Ensure the BigQuery API is enabled, then click Continue.
-
Configure the Data Transfer
-
In the Configure Transfer form, provide the following details:
- Transfer Name: Name the transfer for easy reference.
- Schedule: Choose the data transfer frequency.
- Destination Dataset: Select the dataset created earlier.
- Organization ID: Defaults to the current organization.
- Service Account: Select a service principal to authorize the transfer.
-
Click Create and accept the consent prompt if required.
-
-
Once the initial data transfer completes, your dataset will include the following tables:
insights_exportrecommendations_export
- Send JSON Key: Securely send the generated service account JSON key to Crayon FinOps Team.
- Organization ID: The Google Cloud Organization ID is a 10-digit identifier for your Google Cloud organization.
- Project Name: The Project Name refers to the Google Cloud project where Cloud Billing export to BigQuery is enabled.
- Cloud Billing Dataset ID: The Cloud Billing Dataset ID is the name of the BigQuery dataset where Cloud Billing data is stored. In the BigQuery console, under the project that has Cloud Billing export enabled, you can find the dataset listed in the "Explorer" panel on the left-hand side.
- Table Name: The Table Name refers to the specific table within the Cloud Billing dataset where the billing data is stored. After navigating to the Cloud Billing dataset in BigQuery, you will see a list of tables. The table storing the billing data will be listed there.
- Version 1.0:
- Initial release with instructions for
- Exporting Cloud Billing: Step to enabled the Cloud Billing export to BigQuery.
- Service Account Setup: Added custom roles and JSON key generation for secure access.
- API Enablement: Enabled BigQuery Data Transfer API and Recommender API for seamless integration.
- BigQuery Dataset: Support for exporting recommendations to centralized datasets (
insights_export,recommendations_export). - Data Transfer: Configurable and automated exports via Recommendations Hub.
- Initial release with instructions for
If you encounter any issues or need further assistance, contact Crayon FinOps Team with the details of your project setup and any error messages.
















