Configuration migration

So, I am not sure why this topic hasn’t been discussed yet, but configuration migration should be a first class feature, messing around with the console is dangerous and prone to error, so if you have multiple environments this is not an option.
Also, since the import feature is broken and unreliable, is there any good and easy way to migrate or put my configuration as a code?

Thanks

1 Like

This is an oft-discussed subject. You’re correct that the realm import feature is broken (especially between versions) and generally unreliable. The closest thing that approaches what you’re asking (“configuration as code”) is the terraform provider: https://registry.terraform.io/providers/mrparkers/keycloak/latest/docs
I haven’t personally used it, but I know some people who are using it to manage multiple environments.
I personally use the keycloak admin API with a series of “migrations” where, like a DB migration, I don’t change previous migration scripts once they are run. So, when creating a new environment, I just run all migrations to bring a realm to it’s current state. However, this is also not ideal. I’d prefer if there were some declarative configuration language that exported/imported correctly.

1 Like

Thank you very much for the tips. I will def check the terraform provider.

Hi I use also the Api to configure new environments. It’s quite easy

But how do you do for updates?

This might be a handy tool for handling configs: GitHub - adorsys/keycloak-config-cli: Import YAML/JSON-formatted configuration files into Keycloak - Configuration as Code for Keycloak.

1 Like