From bc1f9e125e14bd91be6c144ba723a9c5ef5c5be2 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Thu, 11 Jul 2024 15:04:24 +0200 Subject: [PATCH] terraform, gcp: micro refactor by reordering in one file --- terraform/gcp/budget-alerts.tf | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/terraform/gcp/budget-alerts.tf b/terraform/gcp/budget-alerts.tf index ad739f8ea..038fc71a2 100644 --- a/terraform/gcp/budget-alerts.tf +++ b/terraform/gcp/budget-alerts.tf @@ -2,6 +2,10 @@ # bad* in the future if left unattended. Should *not* be used for immediate # outages +data "google_project" "project" { + project_id = var.project_id +} + resource "google_monitoring_notification_channel" "support_email" { count = var.budget_alert_enabled ? 1 : 0 project = var.project_id @@ -12,10 +16,6 @@ resource "google_monitoring_notification_channel" "support_email" { } } -data "google_project" "project" { - project_id = var.project_id -} - # 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" { @@ -24,6 +24,13 @@ resource "google_billing_budget" "budget" { billing_account = var.billing_account_id display_name = "Auto-adjusting budget for ${var.prefix}" + all_updates_rule { + monitoring_notification_channels = [ + google_monitoring_notification_channel.support_email[0].id, + ] + disable_default_iam_recipients = true + } + budget_filter { # Use project number here, as project_name seems to be converted internally to number # If we don't do this, `terraform apply` is not clean @@ -37,13 +44,6 @@ resource "google_billing_budget" "budget" { last_period_amount = true } - all_updates_rule { - monitoring_notification_channels = [ - google_monitoring_notification_channel.support_email[0].id, - ] - disable_default_iam_recipients = true - } - # NOTE: These threshold_rules *MUST BE ORDERED BY threshold_percent* in ascending order! # If not, we'll run into https://github.com/hashicorp/terraform-provider-google/issues/8444 # and terraform apply won't be clean.