25 lines
714 B
HCL
25 lines
714 B
HCL
locals {
|
|
sorted-team-names = reverse(distinct(sort([
|
|
for team in var.teams: team.name
|
|
])))
|
|
sorted-teams = flatten([
|
|
for name in local.sorted-team-names: [
|
|
for team in var.teams:
|
|
team if team.name == name
|
|
]
|
|
])
|
|
}
|
|
|
|
resource "authentik_group" "division" {
|
|
name = "div-${var.instance}"
|
|
parent = var.parent
|
|
attributes = jsonencode({for app in var.apps: app => true})
|
|
}
|
|
|
|
resource "authentik_group" "teams" {
|
|
count = length(local.sorted-teams)
|
|
name = "team-${var.instance}-${local.sorted-teams[count.index].name}"
|
|
parent = "div-${var.instance}"
|
|
attributes = jsonencode({for app in local.sorted-teams[count.index].apps: app => true})
|
|
}
|