Skip to content

Commit

Permalink
terraform, gcp: let budget alerts display a reference to related project
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Jul 11, 2024
1 parent 6cfbb49 commit cc6b571
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions terraform/gcp/budget-alerts.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Alerts sent to [email protected] for things that *will go bad* in the future
# if left unattended. Should *not* be used for immediate outages
# Alerts sent to support+budget-${var.prefix}@2i2c.org for things that *will go
# bad* in the future if left unattended. Should *not* be used for immediate
# outages

resource "google_monitoring_notification_channel" "support_email" {
count = var.budget_alert_enabled ? 1 : 0
project = var.project_id
display_name = "[email protected] email"
display_name = "Email support+budget-${var.prefix}@2i2c.org"
type = "email"
labels = {
email_address = "[email protected]"
email_address = "support+budget-${var.prefix}@2i2c.org"
}
}

Expand All @@ -16,11 +17,12 @@ data "google_project" "project" {
}

# Need to explicitly enable https://console.cloud.google.com/apis/library/billingbudgets.googleapis.com?project=two-eye-two-see
# resource ref: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/billing_budget
resource "google_billing_budget" "budget" {
count = var.budget_alert_enabled ? 1 : 0

billing_account = var.billing_account_id
display_name = "Billing alert"
display_name = "Auto-adjusting budget for ${var.prefix}"

budget_filter {
# Use project number here, as project_name seems to be converted internally to number
Expand Down

0 comments on commit cc6b571

Please sign in to comment.