1. Packages
  2. Keycloak Provider
  3. API Docs
  4. DefaultGroups
Keycloak v6.3.0 published on Tuesday, Apr 15, 2025 by Pulumi

keycloak.DefaultGroups

Explore with Pulumi AI

Allows for managing a realm’s default groups.

You should not use keycloak.DefaultGroups with a group whose members are managed by keycloak.GroupMemberships.

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 _default = new keycloak.DefaultGroups("default", {
    realmId: realm.id,
    groupIds: [group.id],
});
Copy
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")
default = keycloak.DefaultGroups("default",
    realm_id=realm.id,
    group_ids=[group.id])
Copy
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
		}
		_, err = keycloak.NewDefaultGroups(ctx, "default", &keycloak.DefaultGroupsArgs{
			RealmId: realm.ID(),
			GroupIds: pulumi.StringArray{
				group.ID(),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
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 @default = new Keycloak.DefaultGroups("default", new()
    {
        RealmId = realm.Id,
        GroupIds = new[]
        {
            @group.Id,
        },
    });

});
Copy
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.DefaultGroups;
import com.pulumi.keycloak.DefaultGroupsArgs;
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 default_ = new DefaultGroups("default", DefaultGroupsArgs.builder()
            .realmId(realm.id())
            .groupIds(group.id())
            .build());

    }
}
Copy
resources:
  realm:
    type: keycloak:Realm
    properties:
      realm: my-realm
      enabled: true
  group:
    type: keycloak:Group
    properties:
      realmId: ${realm.id}
      name: my-group
  default:
    type: keycloak:DefaultGroups
    properties:
      realmId: ${realm.id}
      groupIds:
        - ${group.id}
Copy

Create DefaultGroups Resource

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

Constructor syntax

new DefaultGroups(name: string, args: DefaultGroupsArgs, opts?: CustomResourceOptions);
@overload
def DefaultGroups(resource_name: str,
                  args: DefaultGroupsArgs,
                  opts: Optional[ResourceOptions] = None)

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

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. DefaultGroupsArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. DefaultGroupsArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. DefaultGroupsArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. DefaultGroupsArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. DefaultGroupsArgs
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 defaultGroupsResource = new Keycloak.DefaultGroups("defaultGroupsResource", new()
{
    GroupIds = new[]
    {
        "string",
    },
    RealmId = "string",
});
Copy
example, err := keycloak.NewDefaultGroups(ctx, "defaultGroupsResource", &keycloak.DefaultGroupsArgs{
	GroupIds: pulumi.StringArray{
		pulumi.String("string"),
	},
	RealmId: pulumi.String("string"),
})
Copy
var defaultGroupsResource = new DefaultGroups("defaultGroupsResource", DefaultGroupsArgs.builder()
    .groupIds("string")
    .realmId("string")
    .build());
Copy
default_groups_resource = keycloak.DefaultGroups("defaultGroupsResource",
    group_ids=["string"],
    realm_id="string")
Copy
const defaultGroupsResource = new keycloak.DefaultGroups("defaultGroupsResource", {
    groupIds: ["string"],
    realmId: "string",
});
Copy
type: keycloak:DefaultGroups
properties:
    groupIds:
        - string
    realmId: string
Copy

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

GroupIds This property is required. List<string>
A set of group ids that should be default groups on the realm referenced by realm_id.
RealmId
This property is required.
Changes to this property will trigger replacement.
string
The realm this group exists in.
GroupIds This property is required. []string
A set of group ids that should be default groups on the realm referenced by realm_id.
RealmId
This property is required.
Changes to this property will trigger replacement.
string
The realm this group exists in.
groupIds This property is required. List<String>
A set of group ids that should be default groups on the realm referenced by realm_id.
realmId
This property is required.
Changes to this property will trigger replacement.
String
The realm this group exists in.
groupIds This property is required. string[]
A set of group ids that should be default groups on the realm referenced by realm_id.
realmId
This property is required.
Changes to this property will trigger replacement.
string
The realm this group exists in.
group_ids This property is required. Sequence[str]
A set of group ids that should be default groups on the realm referenced by realm_id.
realm_id
This property is required.
Changes to this property will trigger replacement.
str
The realm this group exists in.
groupIds This property is required. List<String>
A set of group ids that should be default groups on the realm referenced by realm_id.
realmId
This property is required.
Changes to this property will trigger replacement.
String
The realm this group exists in.

Outputs

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

Get an existing DefaultGroups 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?: DefaultGroupsState, opts?: CustomResourceOptions): DefaultGroups
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        group_ids: Optional[Sequence[str]] = None,
        realm_id: Optional[str] = None) -> DefaultGroups
func GetDefaultGroups(ctx *Context, name string, id IDInput, state *DefaultGroupsState, opts ...ResourceOption) (*DefaultGroups, error)
public static DefaultGroups Get(string name, Input<string> id, DefaultGroupsState? state, CustomResourceOptions? opts = null)
public static DefaultGroups get(String name, Output<String> id, DefaultGroupsState state, CustomResourceOptions options)
resources:  _:    type: keycloak:DefaultGroups    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
GroupIds List<string>
A set of group ids that should be default groups on the realm referenced by realm_id.
RealmId Changes to this property will trigger replacement. string
The realm this group exists in.
GroupIds []string
A set of group ids that should be default groups on the realm referenced by realm_id.
RealmId Changes to this property will trigger replacement. string
The realm this group exists in.
groupIds List<String>
A set of group ids that should be default groups on the realm referenced by realm_id.
realmId Changes to this property will trigger replacement. String
The realm this group exists in.
groupIds string[]
A set of group ids that should be default groups on the realm referenced by realm_id.
realmId Changes to this property will trigger replacement. string
The realm this group exists in.
group_ids Sequence[str]
A set of group ids that should be default groups on the realm referenced by realm_id.
realm_id Changes to this property will trigger replacement. str
The realm this group exists in.
groupIds List<String>
A set of group ids that should be default groups on the realm referenced by realm_id.
realmId Changes to this property will trigger replacement. String
The realm this group exists in.

Import

Default groups can be imported using the format {{realm_id}} where realm_id is the realm the group exists in.

Example:

bash

$ pulumi import keycloak:index/defaultGroups:DefaultGroups default my-realm
Copy

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.