Add a limit on billing costs for your GCP account.
https://cloud.google.com/billing/docs/how-to/notify
Navigate to Billing Navigate to Budgets & alerts CREATE BUDGET
Create a cloud function with trigger type Pub/Sub Use the "index.js" and "package.json" scripts. Swap out your project ID in the index.js file.
Provide Billing Administration access to the Cloud Function Service Account
{
"budgetDisplayName": "name-of-budget",
"alertThresholdExceeded": 1.0,
"costAmount": 100.01,
"costIntervalStart": "2019-01-01T00:00:00Z",
"budgetAmount": 100.00,
"budgetAmountType": "SPECIFIED_AMOUNT",
"currencyCode": "USD"
}
https://console.cloud.google.com/billing/linkedaccount?project=macgyver-services-production