# Configuration migration

**URL:** <https://forum.keycloak.org/t/configuration-migration/10022>\
**Category:** Configuring the server\
**Tags:** admin-console\
**Created:** [July 13, 2021, 3:14am UTC](https://forum.keycloak.org/t/configuration-migration/10022 "2021-07-13T03:14:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![oedam](https://avatars.discourse-cdn.com/v4/letter/o/b5a626/32.png) [@oedam](https://forum.keycloak.org/u/oedam)\
**Post date:** [July 13, 2021, 3:14am UTC](https://forum.keycloak.org/t/configuration-migration/10022/1 "2021-07-13T03:14:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [July 14, 2021, 4:13pm UTC](https://forum.keycloak.org/t/configuration-migration/10022/2 "2021-07-14T16:13:21Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![oedam](https://avatars.discourse-cdn.com/v4/letter/o/b5a626/32.png) [@oedam](https://forum.keycloak.org/u/oedam)\
**Post date:** [July 15, 2021, 4:42am UTC](https://forum.keycloak.org/t/configuration-migration/10022/3 "2021-07-15T04:42:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thibaud.benoist](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@thibaud.benoist](https://forum.keycloak.org/u/thibaud.benoist)\
**Post date:** [July 16, 2021, 1:30pm UTC](https://forum.keycloak.org/t/configuration-migration/10022/4 "2021-07-16T13:30:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![oedam](https://avatars.discourse-cdn.com/v4/letter/o/b5a626/32.png) [@oedam](https://forum.keycloak.org/u/oedam)\
**Post date:** [July 27, 2021, 2:42am UTC](https://forum.keycloak.org/t/configuration-migration/10022/5 "2021-07-27T02:42:16Z")

</div>

But how do you do for updates?

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [July 27, 2021, 5:40am UTC](https://forum.keycloak.org/t/configuration-migration/10022/6 "2021-07-27T05:40:12Z")

</div>

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.](https://github.com/adorsys/keycloak-config-cli/)
