terraform-provider-keycloak icon indicating copy to clipboard operation
terraform-provider-keycloak copied to clipboard

[Feature Request] Add an 'import' option for keycloak_realm resources, similar to keycloak_client

Open tculp opened this issue 2 years ago • 3 comments

keycloak_client objects have an 'import' property, which allows one to configure various parameters of clients that were not created by terraform. This type of capability would be useful to have for realms too, especially for the sake of configuring options on the master realm.

This would also solve needs such as https://github.com/mrparkers/terraform-provider-keycloak/issues/597, without requiring the manual terraform import step and introducing a risk of accidentally deleting the master realm.

tculp avatar Jan 13 '23 19:01 tculp

I started with an implementation here: https://github.com/mrparkers/terraform-provider-keycloak/compare/master...mweibel:terraform-provider-keycloak:realm-import

I had issues with importing the master realm afterwards, a second apply would then yield a diff:

 # module.test.keycloak_realm.master will be updated in-place
  ~ resource "keycloak_realm" "master" {
      - default_signature_algorithm              = "RS256" -> null
      - display_name                             = "Keycloak" -> null
      - display_name_html                        = "<div class=\"kc-logo-text\"><span>Keycloak</span></div>" -> null
        id                                       = "master"
        # (44 unchanged attributes hidden)

        # (3 unchanged blocks hidden)
    }

not sure why exactly and didn't find out why before my self-allotted time run out. If anyone wants to continue from here feel free :)

PS: create a ~/.terraformrc with dev_overrides pointing to your local clone to test this (make sure to run make build, too).

mweibel avatar May 17 '23 08:05 mweibel

now that terraform supports the import option natively, this feels redundant I was able to natively to do this: import { id = "master" to = keycloak_realm.master }

dsmorse avatar Mar 15 '24 20:03 dsmorse

The different an 'import' option would still have over the native terraform import is allowing destroys without deleting the realm

tculp avatar Mar 18 '24 02:03 tculp