Skip to content
This repository was archived by the owner on Mar 30, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions gcp/terraform/operations/budget-alert/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Budget-Alert-building-block
This building block sets up a budget on your organization for your project scope.

The following APIs need to be enabled:
- cloud billing API
- service usage API

The service account requires the following permission on the organization level:
- Billing Account Administrator


## Notes:
- Create and upload your backend.tf in input section of the building block definition in meshStack
- add your service account JSON key containings as a string and encrypted environment variable and name it "GOOGLE_CREDENTIALS"
22 changes: 22 additions & 0 deletions gcp/terraform/operations/budget-alert/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
data "google_billing_account" "account" {
billing_account = var.billing_account
}

resource "google_billing_budget" "budget" {
billing_account = data.google_billing_account.account.id

budget_filter {
projects = ["projects/${var.projectid}"]
}

display_name = "${var.projectid}-budget"
amount {
specified_amount {
currency_code = "EUR"
units = var.budget_amount
}
}
threshold_rules {
threshold_percent = var.alert_treshold
}
}
15 changes: 15 additions & 0 deletions gcp/terraform/operations/budget-alert/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "5.8.0"
}
}
}

provider "google" {
project = var.projectid
billing_project = var.projectid
user_project_override = true
}

19 changes: 19 additions & 0 deletions gcp/terraform/operations/budget-alert/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
variable "projectid" {
type = string
description = "Id of the project you want to specify this budget alert for"
}

variable "billing_account" {
type = string
description = "billing account id for your project's organization"
}

variable "budget_amount" {
type = string
description = "The amount of monthly Budget specified for this project"
}

variable "alert_treshold" {
type = string
description = "Ratio of the budget amount that you want to receive an alert when it reached. e.g. '0.5' means 50%"
}