Skip to content

Commit f274d18

Browse files
authored
support project id from subfolders in gcp org (#145)
* creating map of projectid to project number * minor edit * precommit change
1 parent fe6dc4b commit f274d18

File tree

1 file changed

+8
-1
lines changed
  • modules/services/cloud-bench-workload-identity

1 file changed

+8
-1
lines changed

modules/services/cloud-bench-workload-identity/main.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@ data "google_projects" "all_projects" {
66
filter = "parent.id:${data.google_organization.org.org_id} parent.type:organization lifecycleState:ACTIVE"
77
}
88

9+
data "google_project" "project" {
10+
for_each = {
11+
for project_id in local.project_ids : project_id => project_id
12+
}
13+
project_id = each.key
14+
}
15+
916
locals {
1017
# If specific projects are specified, use that list. Otherwise, use all active projects in the org
1118
project_ids = length(var.project_ids) == 0 ? [for p in data.google_projects.all_projects.projects : p.project_id] : var.project_ids
1219

1320
# Fetch both the project ID and project number (Needed by Workload Identity Federation)
14-
project_id_to_number_map = { for p in data.google_projects.all_projects.projects : p.project_id => p.number }
21+
project_id_to_number_map = { for project_id, project in data.google_project.project : project_id => project.number }
1522
}
1623

1724
module "trust_relationship" {

0 commit comments

Comments
 (0)