Fix self-referential authentik_group parents
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful

Adding the first managed group (argocd-admins) exposed a dormant bug: the
groups resource resolved `parents` by indexing authentik_group.this itself,
which OpenTofu rejects as a self-referential block. config/groups/ had been
empty, so `tofu plan` never hit it before.

Pass `parents` through as literal group PKs instead (the resource cannot
reference itself, so parent-by-map-key was never viable). Plan is clean:
3 to add (argocd provider, application, argocd-admins group).
This commit is contained in:
2026-07-12 22:41:56 +10:00
parent 9e75f39a06
commit 7636d45f21
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ resource "authentik_group" "this" {
name = each.value.name name = each.value.name
is_superuser = each.value.is_superuser is_superuser = each.value.is_superuser
parents = each.value.parents != null ? [for p in each.value.parents : authentik_group.this[p].id] : [] parents = each.value.parents
attributes = jsonencode(each.value.attributes) attributes = jsonencode(each.value.attributes)
} }
+2
View File
@@ -2,6 +2,8 @@ variable "groups" {
type = map(object({ type = map(object({
name = string name = string
is_superuser = optional(bool, false) is_superuser = optional(bool, false)
# PKs of existing parent groups. These must be literal group PKs, not keys
# into this map: authentik_group cannot reference itself.
parents = optional(list(string), null) parents = optional(list(string), null)
attributes = optional(map(string), {}) attributes = optional(map(string), {})
})) }))