Export/Import strategy similar to the merge

Hi,

We have different environment like Dev & Prod. While taking new developments from Dev to Prod environment, we always have to manually configure Keycloak configurations like clients, authenticators, mappers etc. Bcz of Keycloak import strategies doesn’t fullfill our requirements. We expect that importing strategies works like the merge. For example, if i update the one client configurations, instead of deleting whole realm, just update the diff.

if we use -Dkeycloak.migration.strategy it either deletes the realm or just ignore if realm exist. In the Prod env. we have thousands of user, groups and roles. Thus, don’t wanna delete or migrate any of groups, roles or users. We couldn’t find a best solution for this problem. Can you advice if any solution exist or similer way to solve it ?

Perhaps https://github.com/adorsys/keycloak-config-cli/ will do it for you?
I didn’t evaluate/use it yet, but I have a similar/other approach for having all the config as code and then will be executed programmatically via admin-api.

Thanks for replying. I have tried the cli but somehow i always get d.a.k.config.KeycloakConfigRunner : HTTP 404 Not Found error, even with simple realm json. There might be something i am missing.

java -jar ./target/keycloak-config-cli.jar --keycloak.url=http://localhost:8080 --keycloak.ssl-verify=true --keycloak.user=admin --keycloak.password=admin --import.path=/Users/smartface/Desktop/test-realm-export.json

2021-01-04 13:55:10.909  WARN 4259 --- [           main] o.s.boot.StartupInfoLogger               : InetAddress.getLocalHost().getHostName() took 5007 milliseconds to respond. Please verify your network configuration (macOS machines may need to add entries to /etc/hosts).
2021-01-04 13:55:15.926  INFO 4259 --- [           main] d.a.k.config.KeycloakConfigApplication   : Starting KeycloakConfigApplication v3.0.0-rc2-SNAPSHOT using Java 1.8.0_242 on MacBook-Pro.local with PID 4259 (/Users/smartface/Desktop/enterprisemiddleware/keycloak-config-cli/target/keycloak-config-cli.jar started by smartface in /Users/smartface/Desktop/enterprisemiddleware/keycloak-config-cli)
2021-01-04 13:55:15.927  INFO 4259 --- [           main] d.a.k.config.KeycloakConfigApplication   : The following profiles are active: @spring.profiles.active@
2021-01-04 13:55:17.597  INFO 4259 --- [           main] d.a.k.config.KeycloakConfigApplication   : Started KeycloakConfigApplication in 17.894 seconds (JVM running for 19.041)
2021-01-04 13:55:18.021  INFO 4259 --- [           main] d.a.k.c.provider.KeycloakImportProvider  : Importing file '/Users/smartface/Desktop/test-realm-export.json'
2021-01-04 13:55:24.737 ERROR 4259 --- [           main] d.a.k.config.KeycloakConfigRunner        : HTTP 404 Not Found
2021-01-04 13:55:24.737  INFO 4259 --- [           main] d.a.k.config.KeycloakConfigRunner        : keycloak-config-cli running in 00:06.717.

sorry my bad, i was using wrong version of cli.