-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject_hierarchy.tf
51 lines (43 loc) · 1.18 KB
/
project_hierarchy.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
resource "google_project" "root" {
name = var.root_project_name
project_id = var.root_project_id
folder_id = var.folder_id
}
resource "google_project_service" "root_iam" {
project = google_project.root.project_id
service = "iam.googleapis.com"
disable_dependent_services = true
}
resource "google_folder" "folder" {
count = length(local.folders)
display_name = local.folders[count.index].display_name
parent = "folders/${var.folder_id}"
}
locals {
all_folder_attributes = [
for folder in google_folder.folder[*] :
{
id = folder.folder_id,
display_name = folder.display_name
}
]
}
resource "google_project" "project" {
count = length(local.projects)
name = local.projects[count.index].name
project_id = local.projects[count.index].id
folder_id = [
for folder in local.all_folder_attributes:
folder.id if folder.display_name == local.projects[count.index].folder
][0]
}
locals {
all_project_attributes = [
for project in google_project.project[*] :
{
id = project.project_id,
name = project.name
folder_id = project.folder_id
}
]
}