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

getGroup

This data source can be used to fetch properties of a Keycloak group for usage with other resources, such as keycloak.GroupRoles.

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 offlineAccess = realm.Id.Apply(id => Keycloak.GetRole.InvokeAsync(new Keycloak.GetRoleArgs
        {
            RealmId = id,
            Name = "offline_access",
        }));
        var @group = realm.Id.Apply(id => Keycloak.GetGroup.InvokeAsync(new Keycloak.GetGroupArgs
        {
            RealmId = id,
            Name = "group",
        }));
        var groupRoles = new Keycloak.GroupRoles("groupRoles", new Keycloak.GroupRolesArgs
        {
            RealmId = realm.Id,
            GroupId = @group.Apply(@group => @group.Id),
            RoleIds = 
            {
                offlineAccess.Apply(offlineAccess => offlineAccess.Id),
            },
        });
    }

}
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
        }
        _, err = keycloak.NewGroupRoles(ctx, "groupRoles", &keycloak.GroupRolesArgs{
            RealmId: realm.ID(),
            GroupId: group.ApplyT(func(group keycloak.LookupGroupResult) (string, error) {
                return group.Id, nil
            }).(pulumi.StringOutput),
            RoleIds: pulumi.StringArray{
                offlineAccess.ApplyT(func(offlineAccess keycloak.LookupRoleResult) (string, error) {
                    return offlineAccess.Id, nil
                }).(pulumi.StringOutput),
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    realm="my-realm",
    enabled=True)
offline_access = realm.id.apply(lambda id: keycloak.get_role(realm_id=id,
    name="offline_access"))
group = realm.id.apply(lambda id: keycloak.get_group(realm_id=id,
    name="group"))
group_roles = keycloak.GroupRoles("groupRoles",
    realm_id=realm.id,
    group_id=group.id,
    role_ids=[offline_access.id])
import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";

const realm = new keycloak.Realm("realm", {
    realm: "my-realm",
    enabled: true,
});
const offlineAccess = realm.id.apply(id => keycloak.getRole({
    realmId: id,
    name: "offline_access",
}));
const group = realm.id.apply(id => keycloak.getGroup({
    realmId: id,
    name: "group",
}));
const groupRoles = new keycloak.GroupRoles("groupRoles", {
    realmId: realm.id,
    groupId: group.id,
    roleIds: [offlineAccess.id],
});

Using getGroup

function getGroup(args: GetGroupArgs, opts?: InvokeOptions): Promise<GetGroupResult>
def get_group(name: Optional[str] = None, realm_id: Optional[str] = None, opts: Optional[InvokeOptions] = None) -> GetGroupResult
func LookupGroup(ctx *Context, args *LookupGroupArgs, opts ...InvokeOption) (*LookupGroupResult, error)

Note: This function is named LookupGroup in the Go SDK.

public static class GetGroup {
    public static Task<GetGroupResult> InvokeAsync(GetGroupArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Name string

The name of the group. If there are multiple groups match name, the first result will be returned.

RealmId string

The realm this group exists within.

Name string

The name of the group. If there are multiple groups match name, the first result will be returned.

RealmId string

The realm this group exists within.

name string

The name of the group. If there are multiple groups match name, the first result will be returned.

realmId string

The realm this group exists within.

name str

The name of the group. If there are multiple groups match name, the first result will be returned.

realm_id str

The realm this group exists within.

getGroup Result

The following output properties are available:

Attributes Dictionary<string, object>
Id string

The provider-assigned unique ID for this managed resource.

Name string
ParentId string
Path string
RealmId string
Attributes map[string]interface{}
Id string

The provider-assigned unique ID for this managed resource.

Name string
ParentId string
Path string
RealmId string
attributes {[key: string]: any}
id string

The provider-assigned unique ID for this managed resource.

name string
parentId string
path string
realmId string
attributes Mapping[str, Any]
id str

The provider-assigned unique ID for this managed resource.

name str
parent_id str
path str
realm_id str

Package Details

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