diff --git a/modules/budget/main.tf b/modules/budget/main.tf index 45bad8b3..2e9bfa52 100644 --- a/modules/budget/main.tf +++ b/modules/budget/main.tf @@ -17,11 +17,11 @@ 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 : @@ -29,6 +29,11 @@ locals { ] } +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