Want to keep tabs on your Google Cloud Platform (GCP) spend for storage and compute in Terra? This article outlines what budget alerts can (and cannot) do, what permissions are needed for these actions, and includes step-by-step instructions for setting up budget alerts for workspaces (after September 27, 2021) or Terra Billing projects (before September 27, 2021).
What GCP budget alerts can (and cannot) do
If you are the GCP Billing account owner or administrator, you can create a GCP budget to monitor your storage, compute and egress charges on Terra.
- Set budgets for the umbrella GCP Billing account or for specific workspaces (after September 27, 2021) or your Terra Billing project (before September 27, 2021).
- Set up email alerts for notification when thresholds are reached.
- Send to GCP Billing account owner.
- Send to up to five additional custom email addresses.
- Use budgets to automate cost control responses.
- Cap billing by disabling GCP Billing accounts.
TIP: Google Cloud Billing Budgets & alerts support configurable budget time periods, beyond monthly budgets. Is your budget tied to an external funding source, such as a grant? Now you can set the budget for the time range of the grant.
GCP budget alerts are at the Google project level (i.e. Terra workspace level, for workspaces created after September 27, 2021). You cannot get information on individual users' spend within a shared workspace with budget alerts.
There is a delay of up to a few days between incurring costs and receiving budget notifications. Due to this latency from the time a resource is used to the time that the activity is billed, you might incur additional costs for usage that hasn't arrived at the time that all services are stopped.
Following the steps in this capping example is not a guarantee that you will not spend more than your budget.
Recommendation: If you have a hard funds limit, set your maximum budget below your available funds to account for billing delays.
What permissions do you need to set up GCP alerts
To set budget alerts on a GCP Billing account
1. You must have owner or admin privileges on the GCP account
To set budget alerts on a Terra workspace
1. You must have owner or admin privileges on the workspace
2. You must have "Viewer" permissions on the GCP Billing account
If any of the actions in the step-by-step instructions are not allowed (grayed out), you probably do not have sufficient permissions.
Free credits example
To change/add GCP Billing account permissions
There are additional fine-grained permissions you can set up to allow specific programmatic actions. To learn more about permissions requirements for programmatic budget alert actions (e.g. disabling billing), see https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#permissions_required_for_this_task.
How to set up a GCP budget alert for a Terra workspace
1. Set budget scope (expand for step-by-step instructions)
1.1. Go to the main navigation menu at the top left on the GCP console (console.cloud.google.com).
1.2. Select Billing. and then the Google Cloud Billing account link (name).
1.3. Choose Budgets and alerts in the left column.
1.4. Click Create budget and, in the form that appears, give your budget a sensible Name.
1.5. Select the project for the budget from the dropdown.
Workspace projects (created by Terra) will have the format "<Terra-billing-project>--<first-15-letters-of-workspace-name>".
To find a specific workspace Google project, open your workspace dashboard page in a separate tab, look under "Workspace Information" on the right column.
1.6. Select the service you want alerts for (i.e. storage, compute).
You can filter the list down by typing in the name of the service you want to track. Services Terra uses include Compute Engine (i.e. VM) and Cloud Storage (i.e. Workspace buckets)
1.7. Click Next to continue.
2. Set the amount (expand for instructions)
2.1. Choose the budget type from the dropdown.
(can be last month's spend, or a specified amount)
2.2. Set the target amount (if you're using a specified amount).
2.3. Click Next to continue.
3. Set alert actions (expand for instructions)
3.1. Set the threshold rules (you can set alerts as a fraction of the total budget or a specific amount, and trigger by actual or forecasted spend).
3.2. Send alert to billing admins and users (selected by default).
3.3. Send alert to up to five additional emails.
3.4. Set up additional actions (e.g. disabling billing) by connecting a Pub/Sub topic to the budget. (for more detailed information about this functionality, see https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications)
Additional GCP documentation about budget alerts
For more details on GCP budget alerts, see https://cloud.google.com/billing/docs/how-to/budgets#permissions_required_to_manage_budgets.
To learn more about additional actions you can program alerts to execute (such as disabling billing), see https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications.