Skip to content

Commit

Permalink
fix: Change budget module to pass project numbers (#550)
Browse files Browse the repository at this point in the history
Co-authored-by: Morgante Pell <morgantep@google.com>
  • Loading branch information
Josh Switnicki and morgante authored Mar 4, 2021
1 parent c9ff841 commit 5c715d8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modules/budget/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,23 @@
locals {
project_name = length(var.projects) == 0 ? "All Projects" : var.projects[0]
display_name = var.display_name == null ? "Budget For ${local.project_name}" : var.display_name
all_updates_rule = var.alert_pubsub_topic == null && var.monitoring_notification_channels == null ? [] : ["1"]
all_updates_rule = var.alert_pubsub_topic == null && length(var.monitoring_notification_channels) == 0 ? [] : ["1"]

projects = length(var.projects) == 0 ? null : [
for id in var.projects :
"projects/${id}"
for project in data.google_project.project :
"projects/${project.number}"
]
services = var.services == null ? null : [
for id in var.services :
"services/${id}"
]
}

data "google_project" "project" {
count = length(var.projects)
project_id = element(var.projects, count.index)
}

resource "google_billing_budget" "budget" {
provider = google-beta
count = var.create_budget ? 1 : 0
Expand Down

0 comments on commit 5c715d8

Please sign in to comment.