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

A way to update existing keycloak_generic_protocol_mapper #1020

Open
NargiT opened this issue Nov 20, 2024 · 2 comments
Open

A way to update existing keycloak_generic_protocol_mapper #1020

NargiT opened this issue Nov 20, 2024 · 2 comments

Comments

@NargiT
Copy link

NargiT commented Nov 20, 2024

Description

For Saml client there is a default role_list client scope with a default mapper impossible to update with the provider.

Discussion

Unfortunately, current terraform provider is not able to toggle the "Single Role Attribute" to true.
I can create a new one, but there are service providers that expect only a list in Role attribute not multiple attribute.

Motivation

Cannot use terraform provider out of the box, need to manually interact with the web app.

Details

Peek.2024-11-20.14-40.mp4

Once I deleted the existing scope, I add this to my .tf and I am good.

resource "keycloak_saml_client_scope" "saml_role_list" {
  name                = "role_list"
  realm_id            = keycloak_realm.realm.id
  consent_screen_text = "$${samlRoleListScopeConsentText}"
  description         = "SAML role list"
}

resource "keycloak_generic_protocol_mapper" "saml_role_attribute_mapper" {
  realm_id        = keycloak_realm.realm.id
  client_scope_id = keycloak_saml_client_scope.saml_role_list.id
  protocol        = "saml"
  protocol_mapper = "saml-role-list-mapper"
  name            = "role"
  config = {
    "single"               = "true"
    "attribute.name"       = "Role"
    "attribute.nameformat" = "Basic"
  }
}
@tiran133
Copy link

You need to import the keycloak_generic_protocol_mapper.saml_role_attribute_mapper first.

https://registry.terraform.io/providers/keycloak/keycloak/latest/docs/resources/generic_protocol_mapper#import

{{realm_id}}/client/{{client_keycloak_id}}/{{protocol_mapper_id}}
{{realm_id}}/client-scope/{{client_scope_keycloak_id}}/{{protocol_mapper_id}}

terraform import keycloak_generic_protocol_mapper.saml_role_attribute_mappermy-realm/client-scope/a7202154-8793-4656-b655-1dd18c181e14/71602afa-f7d1-4788-8c49-ef8fd00af0f4

@NargiT
Copy link
Author

NargiT commented Feb 13, 2025

In order to import a resource you need to know it's ID, this does not work for my case as I am starting a fresh instance and running terraform right after. This breaks the whole point of using terraform.

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

2 participants