mrparkers / terraform-provider-keycloak

Terraform provider for Keycloak
https://registry.terraform.io/providers/mrparkers/keycloak/latest/docs
MIT License
634 stars 313 forks source link

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

Open tculp opened 1 year ago

tculp commented 1 year ago

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.

mweibel commented 1 year ago

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).

dsmorse commented 7 months ago

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 }

tculp commented 7 months ago

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