-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
121 lines (112 loc) · 2.92 KB
/
variables.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
locals {
input = yamldecode(file("secrets.yaml"))
}
locals {
project_group = flatten([for grp_key, group in local.input.group: [for project in group.projects: { group_name=group.name, project_name=project, group_description=group.description} ]])
# Output ex:
# [
# {
# "group_description" = "This is group1"
# "group_name" = "group1"
# "project_name" = "project1"
# },
# {
# "group_description" = "This is group1"
# "group_name" = "group1"
# "project_name" = "project3"
# },
# ]
project_group_map = {for item in local.project_group: "${item.project_name}.${item.group_name}" => item}
# Output ex:
# {
# "projectblue1.blue" = {
# "group_description" = "This is project blue"
# "group_name" = "blue"
# "project_name" = "projectblue1"
# }
# "projectblue2.blue" = {
# "group_description" = "This is project blue"
# "group_name" = "blue"
# "project_name" = "projectblue2"
# }
# }
}
locals {
user_group = flatten([for user in local.input.user: [for group in user.group: {group_name=group.name, user_name=user.username, access=group.access}]])
# Output ex:
# [
# {
# "access" = "guest"
# "group_name" = "group1"
# "user_name" = "user1"
# },
# {
# "access" = "guest"
# "group_name" = "group2"
# "user_name" = "user1"
# },
# {
# "access" = "group21"
# "group_name" = "group12"
# "user_name" = "user2"
# },
# ]
user_group_map = {for item in toset(local.user_group): "${item.user_name}.${item.group_name}" => item}
# Output ex:
# {
# "user1.blue" = {
# "access" = "guest"
# "group_name" = "blue"
# "user_name" = "user1"
# }
# "user1.green" = {
# "access" = "guest"
# "group_name" = "green"
# "user_name" = "user1"
# }
# }
}
locals {
users_map = {for item in local.input.user: item.name => item}
# Output ex:
# {
# "user1" = {
# "email" = "[email protected]"
# "group" = [
# {
# "access" = "guest"
# "name" = "red"
# },
# {
# "access" = "guest"
# "name" = "blue"
# },
# {
# "access" = "guest"
# "name" = "green"
# },
# ]
# "is_admin" = false
# "name" = "user1"
# "password" = "12345f!sddsd"
# "username" = "user1"
# }
# }
}
locals {
group_map = {for item in local.input.group: item.name => item}
# Output ex:
# {
# "blue" = {
# "auto_devops_enabled" = false
# "description" = "This is project blue"
# "name" = "blue"
# "projects" = [
# "projectblue1",
# "projectblue2",
# "projectblue3",
# ]
# "two_factor_grace_period" = 48
# }
# }
}