Skip to content

Commit

Permalink
fix: Change budget module: Accept list of project numbers instead of …
Browse files Browse the repository at this point in the history
…project ID #544
  • Loading branch information
Josh Switnicki committed Feb 24, 2021
1 parent 62c168d commit d575bb8
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 d575bb8

Please sign in to comment.