1. Packages
  2. Keycloak
  3. API Docs
  4. Group
Keycloak v5.3.1 published on Monday, Mar 11, 2024 by Pulumi

keycloak.Group

Explore with Pulumi AI

keycloak logo
Keycloak v5.3.1 published on Monday, Mar 11, 2024 by Pulumi

    # 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", {
        enabled: true,
        realm: "my-realm",
    });
    const parentGroup = new keycloak.Group("parentGroup", {realmId: realm.id});
    const childGroup = new keycloak.Group("childGroup", {
        parentId: parentGroup.id,
        realmId: realm.id,
    });
    const childGroupWithOptionalAttributes = new keycloak.Group("childGroupWithOptionalAttributes", {
        attributes: {
            key1: "value1",
            key2: "value2",
        },
        parentId: parentGroup.id,
        realmId: realm.id,
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        enabled=True,
        realm="my-realm")
    parent_group = keycloak.Group("parentGroup", realm_id=realm.id)
    child_group = keycloak.Group("childGroup",
        parent_id=parent_group.id,
        realm_id=realm.id)
    child_group_with_optional_attributes = keycloak.Group("childGroupWithOptionalAttributes",
        attributes={
            "key1": "value1",
            "key2": "value2",
        },
        parent_id=parent_group.id,
        realm_id=realm.id)
    
    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{
    			Enabled: pulumi.Bool(true),
    			Realm:   pulumi.String("my-realm"),
    		})
    		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{
    			ParentId: parentGroup.ID(),
    			RealmId:  realm.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewGroup(ctx, "childGroupWithOptionalAttributes", &keycloak.GroupArgs{
    			Attributes: pulumi.Map{
    				"key1": pulumi.Any("value1"),
    				"key2": pulumi.Any("value2"),
    			},
    			ParentId: parentGroup.ID(),
    			RealmId:  realm.ID(),
    		})
    		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()
        {
            Enabled = true,
            RealmName = "my-realm",
        });
    
        var parentGroup = new Keycloak.Group("parentGroup", new()
        {
            RealmId = realm.Id,
        });
    
        var childGroup = new Keycloak.Group("childGroup", new()
        {
            ParentId = parentGroup.Id,
            RealmId = realm.Id,
        });
    
        var childGroupWithOptionalAttributes = new Keycloak.Group("childGroupWithOptionalAttributes", new()
        {
            Attributes = 
            {
                { "key1", "value1" },
                { "key2", "value2" },
            },
            ParentId = parentGroup.Id,
            RealmId = realm.Id,
        });
    
    });
    
    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()        
                .enabled(true)
                .realm("my-realm")
                .build());
    
            var parentGroup = new Group("parentGroup", GroupArgs.builder()        
                .realmId(realm.id())
                .build());
    
            var childGroup = new Group("childGroup", GroupArgs.builder()        
                .parentId(parentGroup.id())
                .realmId(realm.id())
                .build());
    
            var childGroupWithOptionalAttributes = new Group("childGroupWithOptionalAttributes", GroupArgs.builder()        
                .attributes(Map.ofEntries(
                    Map.entry("key1", "value1"),
                    Map.entry("key2", "value2")
                ))
                .parentId(parentGroup.id())
                .realmId(realm.id())
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          enabled: true
          realm: my-realm
      parentGroup:
        type: keycloak:Group
        properties:
          realmId: ${realm.id}
      childGroup:
        type: keycloak:Group
        properties:
          parentId: ${parentGroup.id}
          realmId: ${realm.id}
      childGroupWithOptionalAttributes:
        type: keycloak:Group
        properties:
          attributes:
            key1: value1
            key2: value2
          parentId: ${parentGroup.id}
          realmId: ${realm.id}
    

    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
    

    Create Group Resource

    new Group(name: string, args: GroupArgs, opts?: CustomResourceOptions);
    @overload
    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)
    @overload
    def Group(resource_name: str,
              args: GroupArgs,
              opts: Optional[ResourceOptions] = None)
    func NewGroup(ctx *Context, name string, args GroupArgs, opts ...ResourceOption) (*Group, error)
    public Group(string name, GroupArgs args, CustomResourceOptions? opts = null)
    public Group(String name, GroupArgs args)
    public Group(String name, GroupArgs args, CustomResourceOptions options)
    
    type: keycloak:Group
    properties: # The arguments to resource properties.
    options: # 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.
    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.

    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

    The Group resource accepts the following input properties:

    RealmId string
    Attributes Dictionary<string, object>
    Name string
    ParentId string
    RealmId string
    Attributes map[string]interface{}
    Name string
    ParentId string
    realmId String
    attributes Map<String,Object>
    name String
    parentId String
    realmId string
    attributes {[key: string]: any}
    name string
    parentId string
    realm_id str
    attributes Mapping[str, Any]
    name str
    parent_id str
    realmId String
    attributes Map<Any>
    name String
    parentId String

    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
    Id string
    The provider-assigned unique ID for this managed resource.
    Path string
    id String
    The provider-assigned unique ID for this managed resource.
    path String
    id string
    The provider-assigned unique ID for this managed resource.
    path string
    id str
    The provider-assigned unique ID for this managed resource.
    path str
    id String
    The provider-assigned unique ID for this managed resource.
    path String

    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, 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)
    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.
    The following state arguments are supported:
    Attributes Dictionary<string, object>
    Name string
    ParentId string
    Path string
    RealmId string
    Attributes map[string]interface{}
    Name string
    ParentId string
    Path string
    RealmId string
    attributes Map<String,Object>
    name String
    parentId String
    path String
    realmId String
    attributes {[key: string]: any}
    name string
    parentId string
    path string
    realmId string
    attributes Mapping[str, Any]
    name str
    parent_id str
    path str
    realm_id str
    attributes Map<Any>
    name String
    parentId String
    path String
    realmId String

    Package Details

    Repository
    Keycloak pulumi/pulumi-keycloak
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the keycloak Terraform Provider.
    keycloak logo
    Keycloak v5.3.1 published on Monday, Mar 11, 2024 by Pulumi