keycloak / terraform-provider-keycloak

Terraform provider for Keycloak
https://registry.terraform.io/providers/mrparkers/keycloak/latest/docs
Apache License 2.0
648 stars 317 forks source link

Support parent_id in data resource for keycloak_group #873

Open leventyalcin opened 1 year ago

leventyalcin commented 1 year ago

Hi,

I am currently facing a difficulty for fetching group ids for recurring subgroup names. For example; I have groups and subgroups like below:

MainGroup1
|--- Subgroup1
|--- Subgroup2
|--- Subgroup3
MainGroup2
|--- Subgroup1
|--- Subgroup2
|--- Subgroup3

If I have to get the id with:

data "keycloak_group" "maingroup2_subgroup1" {
  realm_id  = data.keycloak_realm.realm.id
  name      = "Subgroup1"
}

the above always returns the first match and I can't get the ID for the Maingroup2->Subgroup1. For example, if the data resource was supporting parent_id, I could use it like:

data "keycloak_group" "maingroup2" {
  realm_id  = data.keycloak_realm.realm.id
  name      = "MainGroup1"
}
data "keycloak_group" "maingroup2_subgroup1" {
  realm_id  = data.keycloak_realm.realm.id
  parent_id = data.keycloak_group.maingroup2.id
  name      = "Subgroup1"
}

In the end I could use the correct ID for the subgroup later.

nevlkv commented 1 year ago

Needed same behavour

dmitry-mightydevops commented 3 weeks ago

yes would be nice to have.