Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

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

using Pulumi;
using Keycloak = Pulumi.Keycloak;

class MyStack : Stack
{
    public MyStack()
    {
        var realm = new Keycloak.Realm("realm", new Keycloak.RealmArgs
        {
            Realm = "my-realm",
            Enabled = true,
        });
        var parentGroup = new Keycloak.Group("parentGroup", new Keycloak.GroupArgs
        {
            RealmId = realm.Id,
        });
        var childGroup = new Keycloak.Group("childGroup", new Keycloak.GroupArgs
        {
            RealmId = realm.Id,
            ParentId = parentGroup.Id,
        });
        var childGroupWithOptionalAttributes = new Keycloak.Group("childGroupWithOptionalAttributes", new Keycloak.GroupArgs
        {
            RealmId = realm.Id,
            ParentId = parentGroup.Id,
            Attributes = 
            {
                { "key1", "value1" },
                { "key2", "value2" },
            },
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-keycloak/sdk/v3/go/keycloak"
    "github.com/pulumi/pulumi/sdk/v2/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, "parentGroup", &keycloak.GroupArgs{
            RealmId: realm.ID(),
        })
        if err != nil {
            return err
        }
        _, err = keycloak.NewGroup(ctx, "childGroup", &keycloak.GroupArgs{
            RealmId:  realm.ID(),
            ParentId: parentGroup.ID(),
        })
        if err != nil {
            return err
        }
        _, err = keycloak.NewGroup(ctx, "childGroupWithOptionalAttributes", &keycloak.GroupArgs{
            RealmId:  realm.ID(),
            ParentId: parentGroup.ID(),
            Attributes: pulumi.StringMap{
                "key1": pulumi.String("value1"),
                "key2": pulumi.String("value2"),
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    realm="my-realm",
    enabled=True)
parent_group = keycloak.Group("parentGroup", realm_id=realm.id)
child_group = keycloak.Group("childGroup",
    realm_id=realm.id,
    parent_id=parent_group.id)
child_group_with_optional_attributes = keycloak.Group("childGroupWithOptionalAttributes",
    realm_id=realm.id,
    parent_id=parent_group.id,
    attributes={
        "key1": "value1",
        "key2": "value2",
    })
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("parentGroup", {realmId: realm.id});
const childGroup = new keycloak.Group("childGroup", {
    realmId: realm.id,
    parentId: parentGroup.id,
});
const childGroupWithOptionalAttributes = new keycloak.Group("childGroupWithOptionalAttributes", {
    realmId: realm.id,
    parentId: parentGroup.id,
    attributes: {
        key1: "value1",
        key2: "value2",
    },
});

Create a Group Resource

new Group(name: string, args: GroupArgs, opts?: CustomResourceOptions);
def Group(resource_name: str, opts: Optional[ResourceOptions] = None, attributes: Optional[Mapping[str, Any]] = None, name: Optional[str] = None, parent_id: Optional[str] = None, realm_id: Optional[str] = None)
func NewGroup(ctx *Context, name string, args GroupArgs, opts ...ResourceOption) (*Group, error)
public Group(string name, GroupArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args GroupArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args GroupArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args GroupArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Group Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The Group resource accepts the following input properties:

RealmId string

The realm this group exists in.

Attributes Dictionary<string, object>

A map of key/value pairs to set as custom attributes for the group.

Name string

The name of the group.

ParentId string

The ID of this group’s parent. If omitted, this group will be defined at the root level.

RealmId string

The realm this group exists in.

Attributes map[string]interface{}

A map of key/value pairs to set as custom attributes for the group.

Name string

The name of the group.

ParentId string

The ID of this group’s parent. If omitted, this group will be defined at the root level.

realmId string

The realm this group exists in.

attributes {[key: string]: any}

A map of key/value pairs to set as custom attributes for the group.

name string

The name of the group.

parentId string

The ID of this group’s parent. If omitted, this group will be defined at the root level.

realm_id str

The realm this group exists in.

attributes Mapping[str, Any]

A map of key/value pairs to set as custom attributes for the group.

name str

The name of the group.

parent_id str

The ID of this group’s parent. If omitted, this group will be defined at the root level.

Outputs

All input properties are implicitly available as output properties. Additionally, the Group resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Path string

(Computed) The complete path of the group. For example, the child group’s path in the example configuration would be /parent-group/child-group.

Id string
The provider-assigned unique ID for this managed resource.
Path string

(Computed) The complete path of the group. For example, the child group’s path in the example configuration would be /parent-group/child-group.

id string
The provider-assigned unique ID for this managed resource.
path string

(Computed) The complete path of the group. For example, the child group’s path in the example configuration would be /parent-group/child-group.

id str
The provider-assigned unique ID for this managed resource.
path str

(Computed) The complete path of the group. For example, the child group’s path in the example configuration would be /parent-group/child-group.

Look up an Existing Group Resource

Get an existing Group resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: GroupState, opts?: CustomResourceOptions): Group
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, attributes: Optional[Mapping[str, Any]] = None, name: Optional[str] = None, parent_id: Optional[str] = None, path: Optional[str] = None, realm_id: Optional[str] = None) -> Group
func GetGroup(ctx *Context, name string, id IDInput, state *GroupState, opts ...ResourceOption) (*Group, error)
public static Group Get(string name, Input<string> id, GroupState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Attributes Dictionary<string, object>

A map of key/value pairs to set as custom attributes for the group.

Name string

The name of the group.

ParentId string

The ID of this group’s parent. If omitted, this group will be defined at the root level.

Path string

(Computed) The complete path of the group. For example, the child group’s path in the example configuration would be /parent-group/child-group.

RealmId string

The realm this group exists in.

Attributes map[string]interface{}

A map of key/value pairs to set as custom attributes for the group.

Name string

The name of the group.

ParentId string

The ID of this group’s parent. If omitted, this group will be defined at the root level.

Path string

(Computed) The complete path of the group. For example, the child group’s path in the example configuration would be /parent-group/child-group.

RealmId string

The realm this group exists in.

attributes {[key: string]: any}

A map of key/value pairs to set as custom attributes for the group.

name string

The name of the group.

parentId string

The ID of this group’s parent. If omitted, this group will be defined at the root level.

path string

(Computed) The complete path of the group. For example, the child group’s path in the example configuration would be /parent-group/child-group.

realmId string

The realm this group exists in.

attributes Mapping[str, Any]

A map of key/value pairs to set as custom attributes for the group.

name str

The name of the group.

parent_id str

The ID of this group’s parent. If omitted, this group will be defined at the root level.

path str

(Computed) The complete path of the group. For example, the child group’s path in the example configuration would be /parent-group/child-group.

realm_id str

The realm this group exists in.

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

 $ pulumi import keycloak:index/group:Group child_group my-realm/934a4a4e-28bd-4703-a0fa-332df153aabd

Package Details

Repository
https://github.com/pulumi/pulumi-keycloak
License
Apache-2.0
Notes
This Pulumi package is based on the keycloak Terraform Provider.