1. Packages
  2. Keycloak Provider
  3. API Docs
  4. GroupMemberships
Keycloak v6.2.1 published on Monday, Feb 3, 2025 by Pulumi

keycloak.GroupMemberships

Explore with Pulumi AI

keycloak logo
Keycloak v6.2.1 published on Monday, Feb 3, 2025 by Pulumi

    Allows for managing a Keycloak group’s members.

    Note that this resource attempts to be an authoritative source over group members. When this resource takes control over a group’s members, users that are manually added to the group will be removed, and users that are manually removed from the group will be added upon the next run of pulumi up.

    Also note that you should not use keycloak.GroupMemberships with a group has been assigned as a default group via keycloak.DefaultGroups.

    This resource should not be used to control membership of a group that has its members federated from an external source via group mapping.

    To non-exclusively manage the group’s of a user, see the keycloak.UserGroups resource

    This resource paginates its data loading on refresh by 50 items.

    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 group = new keycloak.Group("group", {
        realmId: realm.id,
        name: "my-group",
    });
    const user = new keycloak.User("user", {
        realmId: realm.id,
        username: "my-user",
    });
    const groupMembers = new keycloak.GroupMemberships("group_members", {
        realmId: realm.id,
        groupId: group.id,
        members: [user.username],
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    group = keycloak.Group("group",
        realm_id=realm.id,
        name="my-group")
    user = keycloak.User("user",
        realm_id=realm.id,
        username="my-user")
    group_members = keycloak.GroupMemberships("group_members",
        realm_id=realm.id,
        group_id=group.id,
        members=[user.username])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-keycloak/sdk/v6/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(),
    			Name:    pulumi.String("my-group"),
    		})
    		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.NewGroupMemberships(ctx, "group_members", &keycloak.GroupMembershipsArgs{
    			RealmId: realm.ID(),
    			GroupId: group.ID(),
    			Members: pulumi.StringArray{
    				user.Username,
    			},
    		})
    		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 @group = new Keycloak.Group("group", new()
        {
            RealmId = realm.Id,
            Name = "my-group",
        });
    
        var user = new Keycloak.User("user", new()
        {
            RealmId = realm.Id,
            Username = "my-user",
        });
    
        var groupMembers = new Keycloak.GroupMemberships("group_members", new()
        {
            RealmId = realm.Id,
            GroupId = @group.Id,
            Members = new[]
            {
                user.Username,
            },
        });
    
    });
    
    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.GroupMemberships;
    import com.pulumi.keycloak.GroupMembershipsArgs;
    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())
                .name("my-group")
                .build());
    
            var user = new User("user", UserArgs.builder()
                .realmId(realm.id())
                .username("my-user")
                .build());
    
            var groupMembers = new GroupMemberships("groupMembers", GroupMembershipsArgs.builder()
                .realmId(realm.id())
                .groupId(group.id())
                .members(user.username())
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      group:
        type: keycloak:Group
        properties:
          realmId: ${realm.id}
          name: my-group
      user:
        type: keycloak:User
        properties:
          realmId: ${realm.id}
          username: my-user
      groupMembers:
        type: keycloak:GroupMemberships
        name: group_members
        properties:
          realmId: ${realm.id}
          groupId: ${group.id}
          members:
            - ${user.username}
    

    Create GroupMemberships Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new GroupMemberships(name: string, args: GroupMembershipsArgs, opts?: CustomResourceOptions);
    @overload
    def GroupMemberships(resource_name: str,
                         args: GroupMembershipsArgs,
                         opts: Optional[ResourceOptions] = None)
    
    @overload
    def GroupMemberships(resource_name: str,
                         opts: Optional[ResourceOptions] = None,
                         members: Optional[Sequence[str]] = None,
                         realm_id: Optional[str] = None,
                         group_id: Optional[str] = None)
    func NewGroupMemberships(ctx *Context, name string, args GroupMembershipsArgs, opts ...ResourceOption) (*GroupMemberships, error)
    public GroupMemberships(string name, GroupMembershipsArgs args, CustomResourceOptions? opts = null)
    public GroupMemberships(String name, GroupMembershipsArgs args)
    public GroupMemberships(String name, GroupMembershipsArgs args, CustomResourceOptions options)
    
    type: keycloak:GroupMemberships
    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 GroupMembershipsArgs
    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 GroupMembershipsArgs
    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 GroupMembershipsArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args GroupMembershipsArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args GroupMembershipsArgs
    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 groupMembershipsResource = new Keycloak.GroupMemberships("groupMembershipsResource", new()
    {
        Members = new[]
        {
            "string",
        },
        RealmId = "string",
        GroupId = "string",
    });
    
    example, err := keycloak.NewGroupMemberships(ctx, "groupMembershipsResource", &keycloak.GroupMembershipsArgs{
    	Members: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	RealmId: pulumi.String("string"),
    	GroupId: pulumi.String("string"),
    })
    
    var groupMembershipsResource = new GroupMemberships("groupMembershipsResource", GroupMembershipsArgs.builder()
        .members("string")
        .realmId("string")
        .groupId("string")
        .build());
    
    group_memberships_resource = keycloak.GroupMemberships("groupMembershipsResource",
        members=["string"],
        realm_id="string",
        group_id="string")
    
    const groupMembershipsResource = new keycloak.GroupMemberships("groupMembershipsResource", {
        members: ["string"],
        realmId: "string",
        groupId: "string",
    });
    
    type: keycloak:GroupMemberships
    properties:
        groupId: string
        members:
            - string
        realmId: string
    

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

    Members List<string>
    A list of usernames that belong to this group.
    RealmId string
    The realm this group exists in.
    GroupId string
    The ID of the group this resource should manage memberships for.
    Members []string
    A list of usernames that belong to this group.
    RealmId string
    The realm this group exists in.
    GroupId string
    The ID of the group this resource should manage memberships for.
    members List<String>
    A list of usernames that belong to this group.
    realmId String
    The realm this group exists in.
    groupId String
    The ID of the group this resource should manage memberships for.
    members string[]
    A list of usernames that belong to this group.
    realmId string
    The realm this group exists in.
    groupId string
    The ID of the group this resource should manage memberships for.
    members Sequence[str]
    A list of usernames that belong to this group.
    realm_id str
    The realm this group exists in.
    group_id str
    The ID of the group this resource should manage memberships for.
    members List<String>
    A list of usernames that belong to this group.
    realmId String
    The realm this group exists in.
    groupId String
    The ID of the group this resource should manage memberships for.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the GroupMemberships 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 GroupMemberships Resource

    Get an existing GroupMemberships 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?: GroupMembershipsState, opts?: CustomResourceOptions): GroupMemberships
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            group_id: Optional[str] = None,
            members: Optional[Sequence[str]] = None,
            realm_id: Optional[str] = None) -> GroupMemberships
    func GetGroupMemberships(ctx *Context, name string, id IDInput, state *GroupMembershipsState, opts ...ResourceOption) (*GroupMemberships, error)
    public static GroupMemberships Get(string name, Input<string> id, GroupMembershipsState? state, CustomResourceOptions? opts = null)
    public static GroupMemberships get(String name, Output<String> id, GroupMembershipsState state, CustomResourceOptions options)
    resources:  _:    type: keycloak:GroupMemberships    get:      id: ${id}
    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:
    GroupId string
    The ID of the group this resource should manage memberships for.
    Members List<string>
    A list of usernames that belong to this group.
    RealmId string
    The realm this group exists in.
    GroupId string
    The ID of the group this resource should manage memberships for.
    Members []string
    A list of usernames that belong to this group.
    RealmId string
    The realm this group exists in.
    groupId String
    The ID of the group this resource should manage memberships for.
    members List<String>
    A list of usernames that belong to this group.
    realmId String
    The realm this group exists in.
    groupId string
    The ID of the group this resource should manage memberships for.
    members string[]
    A list of usernames that belong to this group.
    realmId string
    The realm this group exists in.
    group_id str
    The ID of the group this resource should manage memberships for.
    members Sequence[str]
    A list of usernames that belong to this group.
    realm_id str
    The realm this group exists in.
    groupId String
    The ID of the group this resource should manage memberships for.
    members List<String>
    A list of usernames that belong to this group.
    realmId String
    The realm this group exists in.

    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.

    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.
    keycloak logo
    Keycloak v6.2.1 published on Monday, Feb 3, 2025 by Pulumi