keycloak logo
Keycloak v5.0.0, Jan 25 23

keycloak.UserGroups

Import

This resource does not support import. Instead of importing, feel free to create this resource as if it did not already exist on the server.

Example Usage

Exhaustive Groups)

using System.Collections.Generic;
using Pulumi;
using Keycloak = Pulumi.Keycloak;

return await Deployment.RunAsync(() => 
{
    var realm = new Keycloak.Realm("realm", new()
    {
        RealmName = "my-realm",
        Enabled = true,
    });

    var @group = new Keycloak.Group("group", new()
    {
        RealmId = realm.Id,
    });

    var user = new Keycloak.User("user", new()
    {
        RealmId = realm.Id,
        Username = "my-user",
    });

    var userGroups = new Keycloak.UserGroups("userGroups", new()
    {
        RealmId = realm.Id,
        UserId = user.Id,
        GroupIds = new[]
        {
            @group.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{
			Realm:   pulumi.String("my-realm"),
			Enabled: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		group, err := keycloak.NewGroup(ctx, "group", &keycloak.GroupArgs{
			RealmId: realm.ID(),
		})
		if err != nil {
			return err
		}
		user, err := keycloak.NewUser(ctx, "user", &keycloak.UserArgs{
			RealmId:  realm.ID(),
			Username: pulumi.String("my-user"),
		})
		if err != nil {
			return err
		}
		_, err = keycloak.NewUserGroups(ctx, "userGroups", &keycloak.UserGroupsArgs{
			RealmId: realm.ID(),
			UserId:  user.ID(),
			GroupIds: pulumi.StringArray{
				group.ID(),
			},
		})
		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 com.pulumi.keycloak.User;
import com.pulumi.keycloak.UserArgs;
import com.pulumi.keycloak.UserGroups;
import com.pulumi.keycloak.UserGroupsArgs;
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 group = new Group("group", GroupArgs.builder()        
            .realmId(realm.id())
            .build());

        var user = new User("user", UserArgs.builder()        
            .realmId(realm.id())
            .username("my-user")
            .build());

        var userGroups = new UserGroups("userGroups", UserGroupsArgs.builder()        
            .realmId(realm.id())
            .userId(user.id())
            .groupIds(group.id())
            .build());

    }
}
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    realm="my-realm",
    enabled=True)
group = keycloak.Group("group", realm_id=realm.id)
user = keycloak.User("user",
    realm_id=realm.id,
    username="my-user")
user_groups = keycloak.UserGroups("userGroups",
    realm_id=realm.id,
    user_id=user.id,
    group_ids=[group.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 group = new keycloak.Group("group", {realmId: realm.id});
const user = new keycloak.User("user", {
    realmId: realm.id,
    username: "my-user",
});
const userGroups = new keycloak.UserGroups("userGroups", {
    realmId: realm.id,
    userId: user.id,
    groupIds: [group.id],
});
resources:
  realm:
    type: keycloak:Realm
    properties:
      realm: my-realm
      enabled: true
  group:
    type: keycloak:Group
    properties:
      realmId: ${realm.id}
  user:
    type: keycloak:User
    properties:
      realmId: ${realm.id}
      username: my-user
  userGroups:
    type: keycloak:UserGroups
    properties:
      realmId: ${realm.id}
      userId: ${user.id}
      groupIds:
        - ${group.id}

Non Exhaustive Groups)

using System.Collections.Generic;
using Pulumi;
using Keycloak = Pulumi.Keycloak;

return await Deployment.RunAsync(() => 
{
    var realm = new Keycloak.Realm("realm", new()
    {
        RealmName = "my-realm",
        Enabled = true,
    });

    var groupFoo = new Keycloak.Group("groupFoo", new()
    {
        RealmId = realm.Id,
    });

    var groupBar = new Keycloak.Group("groupBar", new()
    {
        RealmId = realm.Id,
    });

    var user = new Keycloak.User("user", new()
    {
        RealmId = realm.Id,
        Username = "my-user",
    });

    var userGroupsAssociation1UserGroups = new Keycloak.UserGroups("userGroupsAssociation1UserGroups", new()
    {
        RealmId = realm.Id,
        UserId = user.Id,
        Exhaustive = false,
        GroupIds = new[]
        {
            groupFoo.Id,
        },
    });

    var userGroupsAssociation1Index_userGroupsUserGroups = new Keycloak.UserGroups("userGroupsAssociation1Index/userGroupsUserGroups", new()
    {
        RealmId = realm.Id,
        UserId = user.Id,
        Exhaustive = false,
        GroupIds = new[]
        {
            groupBar.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{
			Realm:   pulumi.String("my-realm"),
			Enabled: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		groupFoo, err := keycloak.NewGroup(ctx, "groupFoo", &keycloak.GroupArgs{
			RealmId: realm.ID(),
		})
		if err != nil {
			return err
		}
		groupBar, err := keycloak.NewGroup(ctx, "groupBar", &keycloak.GroupArgs{
			RealmId: realm.ID(),
		})
		if err != nil {
			return err
		}
		user, err := keycloak.NewUser(ctx, "user", &keycloak.UserArgs{
			RealmId:  realm.ID(),
			Username: pulumi.String("my-user"),
		})
		if err != nil {
			return err
		}
		_, err = keycloak.NewUserGroups(ctx, "userGroupsAssociation1UserGroups", &keycloak.UserGroupsArgs{
			RealmId:    realm.ID(),
			UserId:     user.ID(),
			Exhaustive: pulumi.Bool(false),
			GroupIds: pulumi.StringArray{
				groupFoo.ID(),
			},
		})
		if err != nil {
			return err
		}
		_, err = keycloak.NewUserGroups(ctx, "userGroupsAssociation1Index/userGroupsUserGroups", &keycloak.UserGroupsArgs{
			RealmId:    realm.ID(),
			UserId:     user.ID(),
			Exhaustive: pulumi.Bool(false),
			GroupIds: pulumi.StringArray{
				groupBar.ID(),
			},
		})
		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 com.pulumi.keycloak.User;
import com.pulumi.keycloak.UserArgs;
import com.pulumi.keycloak.UserGroups;
import com.pulumi.keycloak.UserGroupsArgs;
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 groupFoo = new Group("groupFoo", GroupArgs.builder()        
            .realmId(realm.id())
            .build());

        var groupBar = new Group("groupBar", GroupArgs.builder()        
            .realmId(realm.id())
            .build());

        var user = new User("user", UserArgs.builder()        
            .realmId(realm.id())
            .username("my-user")
            .build());

        var userGroupsAssociation1UserGroups = new UserGroups("userGroupsAssociation1UserGroups", UserGroupsArgs.builder()        
            .realmId(realm.id())
            .userId(user.id())
            .exhaustive(false)
            .groupIds(groupFoo.id())
            .build());

        var userGroupsAssociation1Index_userGroupsUserGroups = new UserGroups("userGroupsAssociation1Index/userGroupsUserGroups", UserGroupsArgs.builder()        
            .realmId(realm.id())
            .userId(user.id())
            .exhaustive(false)
            .groupIds(groupBar.id())
            .build());

    }
}
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    realm="my-realm",
    enabled=True)
group_foo = keycloak.Group("groupFoo", realm_id=realm.id)
group_bar = keycloak.Group("groupBar", realm_id=realm.id)
user = keycloak.User("user",
    realm_id=realm.id,
    username="my-user")
user_groups_association1_user_groups = keycloak.UserGroups("userGroupsAssociation1UserGroups",
    realm_id=realm.id,
    user_id=user.id,
    exhaustive=False,
    group_ids=[group_foo.id])
user_groups_association1_index_user_groups_user_groups = keycloak.UserGroups("userGroupsAssociation1Index/userGroupsUserGroups",
    realm_id=realm.id,
    user_id=user.id,
    exhaustive=False,
    group_ids=[group_bar.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 groupFoo = new keycloak.Group("groupFoo", {realmId: realm.id});
const groupBar = new keycloak.Group("groupBar", {realmId: realm.id});
const user = new keycloak.User("user", {
    realmId: realm.id,
    username: "my-user",
});
const userGroupsAssociation1UserGroups = new keycloak.UserGroups("userGroupsAssociation1UserGroups", {
    realmId: realm.id,
    userId: user.id,
    exhaustive: false,
    groupIds: [groupFoo.id],
});
const userGroupsAssociation1Index_userGroupsUserGroups = new keycloak.UserGroups("userGroupsAssociation1Index/userGroupsUserGroups", {
    realmId: realm.id,
    userId: user.id,
    exhaustive: false,
    groupIds: [groupBar.id],
});
resources:
  realm:
    type: keycloak:Realm
    properties:
      realm: my-realm
      enabled: true
  groupFoo:
    type: keycloak:Group
    properties:
      realmId: ${realm.id}
  groupBar:
    type: keycloak:Group
    properties:
      realmId: ${realm.id}
  user:
    type: keycloak:User
    properties:
      realmId: ${realm.id}
      username: my-user
  userGroupsAssociation1UserGroups:
    type: keycloak:UserGroups
    properties:
      realmId: ${realm.id}
      userId: ${user.id}
      exhaustive: false
      groupIds:
        - ${groupFoo.id}
  userGroupsAssociation1Index/userGroupsUserGroups:
    type: keycloak:UserGroups
    properties:
      realmId: ${realm.id}
      userId: ${user.id}
      exhaustive: false
      groupIds:
        - ${groupBar.id}

Create UserGroups Resource

new UserGroups(name: string, args: UserGroupsArgs, opts?: CustomResourceOptions);
@overload
def UserGroups(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               exhaustive: Optional[bool] = None,
               group_ids: Optional[Sequence[str]] = None,
               realm_id: Optional[str] = None,
               user_id: Optional[str] = None)
@overload
def UserGroups(resource_name: str,
               args: UserGroupsArgs,
               opts: Optional[ResourceOptions] = None)
func NewUserGroups(ctx *Context, name string, args UserGroupsArgs, opts ...ResourceOption) (*UserGroups, error)
public UserGroups(string name, UserGroupsArgs args, CustomResourceOptions? opts = null)
public UserGroups(String name, UserGroupsArgs args)
public UserGroups(String name, UserGroupsArgs args, CustomResourceOptions options)
type: keycloak:UserGroups
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args UserGroupsArgs
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 UserGroupsArgs
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 UserGroupsArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args UserGroupsArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args UserGroupsArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

UserGroups 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 UserGroups resource accepts the following input properties:

GroupIds List<string>

A list of group IDs that the user is member of.

RealmId string

The realm this group exists in.

UserId string

The ID of the user this resource should manage groups for.

Exhaustive bool

Indicates if the list of the user's groups is exhaustive. In this case, groups that are manually added to the user will be removed. Defaults to true.

GroupIds []string

A list of group IDs that the user is member of.

RealmId string

The realm this group exists in.

UserId string

The ID of the user this resource should manage groups for.

Exhaustive bool

Indicates if the list of the user's groups is exhaustive. In this case, groups that are manually added to the user will be removed. Defaults to true.

groupIds List<String>

A list of group IDs that the user is member of.

realmId String

The realm this group exists in.

userId String

The ID of the user this resource should manage groups for.

exhaustive Boolean

Indicates if the list of the user's groups is exhaustive. In this case, groups that are manually added to the user will be removed. Defaults to true.

groupIds string[]

A list of group IDs that the user is member of.

realmId string

The realm this group exists in.

userId string

The ID of the user this resource should manage groups for.

exhaustive boolean

Indicates if the list of the user's groups is exhaustive. In this case, groups that are manually added to the user will be removed. Defaults to true.

group_ids Sequence[str]

A list of group IDs that the user is member of.

realm_id str

The realm this group exists in.

user_id str

The ID of the user this resource should manage groups for.

exhaustive bool

Indicates if the list of the user's groups is exhaustive. In this case, groups that are manually added to the user will be removed. Defaults to true.

groupIds List<String>

A list of group IDs that the user is member of.

realmId String

The realm this group exists in.

userId String

The ID of the user this resource should manage groups for.

exhaustive Boolean

Indicates if the list of the user's groups is exhaustive. In this case, groups that are manually added to the user will be removed. Defaults to true.

Outputs

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

Id string

The provider-assigned unique ID for this managed resource.

Id string

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

id string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up Existing UserGroups Resource

Get an existing UserGroups 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?: UserGroupsState, opts?: CustomResourceOptions): UserGroups
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        exhaustive: Optional[bool] = None,
        group_ids: Optional[Sequence[str]] = None,
        realm_id: Optional[str] = None,
        user_id: Optional[str] = None) -> UserGroups
func GetUserGroups(ctx *Context, name string, id IDInput, state *UserGroupsState, opts ...ResourceOption) (*UserGroups, error)
public static UserGroups Get(string name, Input<string> id, UserGroupsState? state, CustomResourceOptions? opts = null)
public static UserGroups get(String name, Output<String> id, UserGroupsState 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:
Exhaustive bool

Indicates if the list of the user's groups is exhaustive. In this case, groups that are manually added to the user will be removed. Defaults to true.

GroupIds List<string>

A list of group IDs that the user is member of.

RealmId string

The realm this group exists in.

UserId string

The ID of the user this resource should manage groups for.

Exhaustive bool

Indicates if the list of the user's groups is exhaustive. In this case, groups that are manually added to the user will be removed. Defaults to true.

GroupIds []string

A list of group IDs that the user is member of.

RealmId string

The realm this group exists in.

UserId string

The ID of the user this resource should manage groups for.

exhaustive Boolean

Indicates if the list of the user's groups is exhaustive. In this case, groups that are manually added to the user will be removed. Defaults to true.

groupIds List<String>

A list of group IDs that the user is member of.

realmId String

The realm this group exists in.

userId String

The ID of the user this resource should manage groups for.

exhaustive boolean

Indicates if the list of the user's groups is exhaustive. In this case, groups that are manually added to the user will be removed. Defaults to true.

groupIds string[]

A list of group IDs that the user is member of.

realmId string

The realm this group exists in.

userId string

The ID of the user this resource should manage groups for.

exhaustive bool

Indicates if the list of the user's groups is exhaustive. In this case, groups that are manually added to the user will be removed. Defaults to true.

group_ids Sequence[str]

A list of group IDs that the user is member of.

realm_id str

The realm this group exists in.

user_id str

The ID of the user this resource should manage groups for.

exhaustive Boolean

Indicates if the list of the user's groups is exhaustive. In this case, groups that are manually added to the user will be removed. Defaults to true.

groupIds List<String>

A list of group IDs that the user is member of.

realmId String

The realm this group exists in.

userId String

The ID of the user this resource should manage groups for.

Package Details

Repository
Keycloak pulumi/pulumi-keycloak
License
Apache-2.0
Notes

This Pulumi package is based on the keycloak Terraform Provider.