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

Cannot enable keycloak organizations on an existing realm #1073

Open
srcinemo opened this issue Jan 14, 2025 · 0 comments · May be fixed by #1076
Open

Cannot enable keycloak organizations on an existing realm #1073

srcinemo opened this issue Jan 14, 2025 · 0 comments · May be fixed by #1076

Comments

@srcinemo
Copy link

srcinemo commented Jan 14, 2025

Describe the bug

I have existing realms in my keycloak instance which were created by this provider. Now we have a requirement to enable "organizations" for these existing realms.
I saw this is not currently supported by this terraform provider. Then i tried the workaround using "magodo/restful" provider as suggested here but everytime i try to update the realms i get a "Conflict detected" error. Below is the terraform code i am trying to apply to update my existing realms. Please help! Please note, because of the number of realms across multiple keycloak instances , it is not possible to migrate them to the restful provider.

`resource "keycloak_realm" "realmdemo5" {
realm = "demo5"
enabled = true
display_name = "demo5"
ssl_required = "external"

registration_allowed = true
reset_password_allowed = true
registration_email_as_username = true
login_with_email_allowed = true
remember_me = true
verify_email = true
edit_username_allowed = true

attributes = {
userProfileEnabled = true
}

access_code_lifespan = "1h"

password_policy = var.password_policy

...
}

resource "restful_resource" "realmdemo5restful" {
check_existance = false
merge_patch_disabled = false
provider = restful
path = "/admin/realms"
#update_path = "$(path)/demo5"
update_path = "$(path)/demo5"
read_selector = "#(realm=="demo5")"
query = {
api-version = ["2020-06-01"]
}
update_method = "PUT"
body = {
realm = "demo5",
organizationsEnabled = true
}
}`

Version

26.0.5

Expected behavior

The organisation should be enabled under "Realm settings" using terraform

Actual behavior

Error: Create API returns 409

│ with restful_resource.realmdemo5restful,
│ on realm.tf line ***, in resource "restful_resource" "realmdemo5restful":
│ 481: resource "restful_resource" "realmdemo5restful" {

│ {"errorMessage":"Conflict detected. See logs for details"}

How to Reproduce?

No response

Anything else?

No response

@sschu sschu linked a pull request Jan 15, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant