keycloak.Group
Explore with Pulumi AI
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: {
foo: "bar",
multivalue: "value1##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={
"foo": "bar",
"multivalue": "value1##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.StringMap{
"foo": pulumi.String("bar"),
"multivalue": pulumi.String("value1##value2"),
},
})
if err != nil {
return err
}
return nil
})
}
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 =
{
{ "foo", "bar" },
{ "multivalue", "value1##value2" },
},
});
});
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("foo", "bar"),
Map.entry("multivalue", "value1##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:
foo: bar
multivalue: value1##value2
Create Group Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Group(name: string, args: GroupArgs, opts?: CustomResourceOptions);
@overload
def Group(resource_name: str,
args: GroupArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Group(resource_name: str,
opts: Optional[ResourceOptions] = None,
realm_id: Optional[str] = None,
attributes: Optional[Mapping[str, str]] = None,
name: Optional[str] = None,
parent_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)
type: keycloak:Group
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- 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.
- args GroupArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control 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.
- name String
- The unique name of the resource.
- args GroupArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var groupResource = new Keycloak.Group("groupResource", new()
{
RealmId = "string",
Attributes =
{
{ "string", "string" },
},
Name = "string",
ParentId = "string",
});
example, err := keycloak.NewGroup(ctx, "groupResource", &keycloak.GroupArgs{
RealmId: pulumi.String("string"),
Attributes: pulumi.StringMap{
"string": pulumi.String("string"),
},
Name: pulumi.String("string"),
ParentId: pulumi.String("string"),
})
var groupResource = new Group("groupResource", GroupArgs.builder()
.realmId("string")
.attributes(Map.of("string", "string"))
.name("string")
.parentId("string")
.build());
group_resource = keycloak.Group("groupResource",
realm_id="string",
attributes={
"string": "string",
},
name="string",
parent_id="string")
const groupResource = new keycloak.Group("groupResource", {
realmId: "string",
attributes: {
string: "string",
},
name: "string",
parentId: "string",
});
type: keycloak:Group
properties:
attributes:
string: string
name: string
parentId: string
realmId: string
Group Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Group resource accepts the following input properties:
- Realm
Id string - The realm this group exists in.
- Attributes Dictionary<string, string>
- A map representing attributes for the group. In order to add multivalue attributes, use
##
to seperate the values. Max length for each value is 255 chars - Name string
- The name of the group.
- Parent
Id string - The ID of this group's parent. If omitted, this group will be defined at the root level.
- Realm
Id string - The realm this group exists in.
- Attributes map[string]string
- A map representing attributes for the group. In order to add multivalue attributes, use
##
to seperate the values. Max length for each value is 255 chars - Name string
- The name of the group.
- Parent
Id string - The ID of this group's parent. If omitted, this group will be defined at the root level.
- realm
Id String - The realm this group exists in.
- attributes Map<String,String>
- A map representing attributes for the group. In order to add multivalue attributes, use
##
to seperate the values. Max length for each value is 255 chars - name String
- The name of the group.
- parent
Id String - The ID of this group's parent. If omitted, this group will be defined at the root level.
- realm
Id string - The realm this group exists in.
- attributes {[key: string]: string}
- A map representing attributes for the group. In order to add multivalue attributes, use
##
to seperate the values. Max length for each value is 255 chars - name string
- The name of the group.
- parent
Id 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, str]
- A map representing attributes for the group. In order to add multivalue attributes, use
##
to seperate the values. Max length for each value is 255 chars - 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.
- realm
Id String - The realm this group exists in.
- attributes Map<String>
- A map representing attributes for the group. In order to add multivalue attributes, use
##
to seperate the values. Max length for each value is 255 chars - name String
- The name of the group.
- parent
Id String - 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:
Look up 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, str]] = 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)
public static Group get(String name, Output<String> id, GroupState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- 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.
- 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.
- Attributes Dictionary<string, string>
- A map representing attributes for the group. In order to add multivalue attributes, use
##
to seperate the values. Max length for each value is 255 chars - Name string
- The name of the group.
- Parent
Id 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
. - Realm
Id string - The realm this group exists in.
- Attributes map[string]string
- A map representing attributes for the group. In order to add multivalue attributes, use
##
to seperate the values. Max length for each value is 255 chars - Name string
- The name of the group.
- Parent
Id 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
. - Realm
Id string - The realm this group exists in.
- attributes Map<String,String>
- A map representing attributes for the group. In order to add multivalue attributes, use
##
to seperate the values. Max length for each value is 255 chars - name String
- The name of the group.
- parent
Id 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
. - realm
Id String - The realm this group exists in.
- attributes {[key: string]: string}
- A map representing attributes for the group. In order to add multivalue attributes, use
##
to seperate the values. Max length for each value is 255 chars - name string
- The name of the group.
- parent
Id 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
. - realm
Id string - The realm this group exists in.
- attributes Mapping[str, str]
- A map representing attributes for the group. In order to add multivalue attributes, use
##
to seperate the values. Max length for each value is 255 chars - 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.
- attributes Map<String>
- A map representing attributes for the group. In order to add multivalue attributes, use
##
to seperate the values. Max length for each value is 255 chars - name String
- The name of the group.
- parent
Id 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
. - realm
Id String - 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.
Example:
bash
$ pulumi import keycloak:index/group:Group child_group my-realm/934a4a4e-28bd-4703-a0fa-332df153aabd
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Keycloak pulumi/pulumi-keycloak
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
keycloak
Terraform Provider.