GroupArgs

data class GroupArgs(val attributes: Output<Map<String, Any>>? = null, val name: Output<String>? = null, val parentId: Output<String>? = null, val realmId: Output<String>? = null) : ConvertibleToJava<GroupArgs>

# keycloak.Group

Allows for creating and managing Groups within Keycloak. Groups provide a logical wrapping for users within Keycloak. Users within a group can share attributes and roles, and group membership can be mapped to a claim. Attributes can also be defined on Groups. Groups can also be federated from external data sources, such as LDAP or Active Directory. This resource should not be used to manage groups that were created this way.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";
const realm = new keycloak.Realm("realm", {
realm: "my-realm",
enabled: true,
});
const parentGroup = new keycloak.Group("parent_group", {
realmId: realm.id,
name: "parent-group",
});
const childGroup = new keycloak.Group("child_group", {
realmId: realm.id,
parentId: parentGroup.id,
name: "child-group",
});
const childGroupWithOptionalAttributes = new keycloak.Group("child_group_with_optional_attributes", {
realmId: realm.id,
parentId: parentGroup.id,
name: "child-group-with-optional-attributes",
attributes: {
key1: "value1",
key2: "value2",
},
});
import pulumi
import pulumi_keycloak as keycloak
realm = keycloak.Realm("realm",
realm="my-realm",
enabled=True)
parent_group = keycloak.Group("parent_group",
realm_id=realm.id,
name="parent-group")
child_group = keycloak.Group("child_group",
realm_id=realm.id,
parent_id=parent_group.id,
name="child-group")
child_group_with_optional_attributes = keycloak.Group("child_group_with_optional_attributes",
realm_id=realm.id,
parent_id=parent_group.id,
name="child-group-with-optional-attributes",
attributes={
"key1": "value1",
"key2": "value2",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Keycloak = Pulumi.Keycloak;
return await Deployment.RunAsync(() =>
{
var realm = new Keycloak.Realm("realm", new()
{
RealmName = "my-realm",
Enabled = true,
});
var parentGroup = new Keycloak.Group("parent_group", new()
{
RealmId = realm.Id,
Name = "parent-group",
});
var childGroup = new Keycloak.Group("child_group", new()
{
RealmId = realm.Id,
ParentId = parentGroup.Id,
Name = "child-group",
});
var childGroupWithOptionalAttributes = new Keycloak.Group("child_group_with_optional_attributes", new()
{
RealmId = realm.Id,
ParentId = parentGroup.Id,
Name = "child-group-with-optional-attributes",
Attributes =
{
{ "key1", "value1" },
{ "key2", "value2" },
},
});
});
package main
import (
"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
realm, err := keycloak.NewRealm(ctx, "realm", &keycloak.RealmArgs{
Realm: pulumi.String("my-realm"),
Enabled: pulumi.Bool(true),
})
if err != nil {
return err
}
parentGroup, err := keycloak.NewGroup(ctx, "parent_group", &keycloak.GroupArgs{
RealmId: realm.ID(),
Name: pulumi.String("parent-group"),
})
if err != nil {
return err
}
_, err = keycloak.NewGroup(ctx, "child_group", &keycloak.GroupArgs{
RealmId: realm.ID(),
ParentId: parentGroup.ID(),
Name: pulumi.String("child-group"),
})
if err != nil {
return err
}
_, err = keycloak.NewGroup(ctx, "child_group_with_optional_attributes", &keycloak.GroupArgs{
RealmId: realm.ID(),
ParentId: parentGroup.ID(),
Name: pulumi.String("child-group-with-optional-attributes"),
Attributes: pulumi.Map{
"key1": pulumi.Any("value1"),
"key2": pulumi.Any("value2"),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.keycloak.Realm;
import com.pulumi.keycloak.RealmArgs;
import com.pulumi.keycloak.Group;
import com.pulumi.keycloak.GroupArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var realm = new Realm("realm", RealmArgs.builder()
.realm("my-realm")
.enabled(true)
.build());
var parentGroup = new Group("parentGroup", GroupArgs.builder()
.realmId(realm.id())
.name("parent-group")
.build());
var childGroup = new Group("childGroup", GroupArgs.builder()
.realmId(realm.id())
.parentId(parentGroup.id())
.name("child-group")
.build());
var childGroupWithOptionalAttributes = new Group("childGroupWithOptionalAttributes", GroupArgs.builder()
.realmId(realm.id())
.parentId(parentGroup.id())
.name("child-group-with-optional-attributes")
.attributes(Map.ofEntries(
Map.entry("key1", "value1"),
Map.entry("key2", "value2")
))
.build());
}
}
resources:
realm:
type: keycloak:Realm
properties:
realm: my-realm
enabled: true
parentGroup:
type: keycloak:Group
name: parent_group
properties:
realmId: ${realm.id}
name: parent-group
childGroup:
type: keycloak:Group
name: child_group
properties:
realmId: ${realm.id}
parentId: ${parentGroup.id}
name: child-group
childGroupWithOptionalAttributes:
type: keycloak:Group
name: child_group_with_optional_attributes
properties:
realmId: ${realm.id}
parentId: ${parentGroup.id}
name: child-group-with-optional-attributes
attributes:
key1: value1
key2: value2

Argument Reference

The following arguments are supported:

  • realm_id - (Required) The realm this group exists in.

  • parent_id - (Optional) The ID of this group's parent. If omitted, this group will be defined at the root level.

  • name - (Required) The name of the group.

  • attributes - (Optional) A dict of key/value pairs to set as custom attributes for the group.

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • path - The complete path of the group. For example, the child group's path in the example configuration would be /parent-group/child-group.

Import

Groups can be imported using the format {{realm_id}}/{{group_id}}, where group_id is the unique ID that Keycloak assigns to the group upon creation. This value can be found in the URI when editing this group in the GUI, and is typically a GUID. Example:

$ terraform import keycloak_group.child_group my-realm/934a4a4e-28bd-4703-a0fa-332df153aabd

Constructors

Link copied to clipboard
constructor(attributes: Output<Map<String, Any>>? = null, name: Output<String>? = null, parentId: Output<String>? = null, realmId: Output<String>? = null)

Properties

Link copied to clipboard
val attributes: Output<Map<String, Any>>? = null
Link copied to clipboard
val name: Output<String>? = null
Link copied to clipboard
val parentId: Output<String>? = null
Link copied to clipboard
val realmId: Output<String>? = null

Functions

Link copied to clipboard
open override fun toJava(): GroupArgs