resource "google_project_service" "billingbudgets" { service = "billingbudgets.googleapis.com" disable_on_destroy = false } resource "google_monitoring_notification_channel" "email" { display_name = "Forgejo budget alerts" type = "email" labels = { email_address = var.admin_email } } resource "google_billing_budget" "forgejo" { billing_account = var.billing_account display_name = "Forgejo project (${var.project_id})" budget_filter { projects = ["projects/${var.project_id}"] } amount { specified_amount { currency_code = "USD" units = tostring(var.budget_amount_usd) } } threshold_rules { threshold_percent = 0.5 } threshold_rules { threshold_percent = 0.9 } threshold_rules { threshold_percent = 1.0 } threshold_rules { threshold_percent = 1.0 spend_basis = "FORECASTED_SPEND" } all_updates_rule { monitoring_notification_channels = [ google_monitoring_notification_channel.email.id, ] disable_default_iam_recipients = false } depends_on = [google_project_service.billingbudgets] }