Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to update role's associated roles with new resource rather then while creating it with keycloak_role resource #1032

Open
BoyFromDubai opened this issue Dec 16, 2024 · 0 comments

Comments

@BoyFromDubai
Copy link

Description

Allow to update role's associated roles with new resource, that will allow only update associated roles of an existing one, rather then associate roles while only creating a new role

Discussion

No response

Motivation

While creating roles using a loop, you cannot update here composite_roles, as you get Cycle error:

resource "keycloak_role" "this" {
  for_each = { for entry in local.roles : entry.name_link => entry }

  realm_id  = var.realms[each.value.realm_name].id
  name      = each.value.name
  client_id = lookup(each.value, "client_name", null) != null ? var.client_ids["${each.value.realm_name}.${each.value.client_name}"] : null
  composite_roles = [
       keycloak_role.this[each.value.composite_role_name]
  ]
  description = each.value.description
}

And also you cannot use another keycloak_role resource to update associated roles as tf throws an error that this role already exists because it tries to create a new one with the same name

Details

It would be great to have a resource like this:

resource "keycloak_composite_role" "this" {
  for_each = { for entry in local.roles : entry.name_link => entry }

  realm_id  = var.realms[each.value.realm_name].id
  role_id = main_role_id
  composite_roles = [
    some_role_id,
    another_role_id
  ]
}

And this resource will only update already existing role and add them associated roles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant