mrparkers / terraform-provider-keycloak

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

Manually set realm ID #800

Closed cpesch closed 1 year ago

cpesch commented 1 year ago

A step forward to address issue #634

I want to allow the usage of all realm names that are currently not used. Due to Keycloaks "feature" to use the realm names for the ID, I'd additionally need to deny the usage of all realm names that were used at creation time and I'd like to avoid that.

Successfully tested with

locals {
  realms = {
    "abc" = {},
    "def" = {}
  }
}

resource "keycloak_realm" "id_realm" {
  for_each     = local.realms
  internal_id  = "my-${each.key}-id"
  realm        = "my-id-${each.key}-realm-name"
}

resource "keycloak_realm" "name_realm" {
  for_each     = local.realms
  realm        = "my-named-${each.key}-realm"
}

@mrparkers @dmeyerholt please have a look

dmeyerholt commented 1 year ago

Thanks for taking over this issue @cpesch .as long as the older tests from the initial PR are still working it should be fine. will try your branch in a local build with our extensive config this week. Maybe adding some tests for your use case could be added.

mrparkers commented 1 year ago

Hi @cpesch, I ended up opening #807 for this instead to add a test for this. Thanks for your effort here!