Dateien nach "keycloak-tf-projekt" hochladen
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
provider "keycloak" {
|
||||
url = var.keycloak_url
|
||||
|
||||
realm = "master"
|
||||
client_id = "admin-cli"
|
||||
|
||||
username = var.keycloak_username
|
||||
password = var.keycloak_password
|
||||
}
|
||||
|
||||
locals {
|
||||
realm_config_files = fileset("./realms", "*.json")
|
||||
all_realm_configs = {
|
||||
for filename in local.realm_config_files :
|
||||
trimsuffix(basename(filename), ".json") => jsondecode(file("${path.module}/realms/${filename}"))
|
||||
}
|
||||
|
||||
# Nimm das ERSTE Objekt in der Liste (den ersten Benutzer)
|
||||
config_user_raw = file("./users.csv")
|
||||
config_user_data = csvdecode(local.config_user_raw)
|
||||
|
||||
user_map_from_csv = {
|
||||
for user_obj in local.config_user_data : user_obj.username => user_obj
|
||||
}
|
||||
}
|
||||
|
||||
resource "keycloak_realm" "test_realm" {
|
||||
for_each = local.all_realm_configs
|
||||
|
||||
realm = each.value.realm
|
||||
enabled = each.value.enabled
|
||||
}
|
||||
|
||||
module "keycloak_clients" {
|
||||
// Der Pfad zu Ihrem Modul-Ordner
|
||||
source = "./modules/clients"
|
||||
|
||||
// Übergabe der Realm ID an die Variable "realm_id" des Moduls
|
||||
realm_id = keycloak_realm.test_realm["first"].id
|
||||
}
|
||||
|
||||
# data "keycloak_openid_client" "web_app_client_data" {
|
||||
# realm_id = keycloak_realm.test_realm["first"].id
|
||||
# client_id = "my-web-app-client"
|
||||
# }
|
||||
|
||||
module "keycloak_users" {
|
||||
source = "./modules/users"
|
||||
|
||||
# Übergabe der Realm ID und der Benutzer-Details
|
||||
realm_id = keycloak_realm.test_realm["first"].id
|
||||
usernames = local.user_map_from_csv
|
||||
|
||||
target_client_id = module.keycloak_clients.all_client_ids_map.my-web-app-client
|
||||
role_to_assign = "user"
|
||||
}
|
||||
Reference in New Issue
Block a user