DefaultRoles

Allows managing default realm roles within Keycloak.

Note: This feature was added in Keycloak v13, so this resource will not work on older versions of Keycloak.

Example Usage

Realm Role)

using Pulumi;
using Keycloak = Pulumi.Keycloak;

class MyStack : Stack
{
    public MyStack()
    {
        var realm = new Keycloak.Realm("realm", new Keycloak.RealmArgs
        {
            Realm = "my-realm",
            Enabled = true,
        });
        var defalutRoles = new Keycloak.DefaultRoles("defalutRoles", new Keycloak.DefaultRolesArgs
        {
            RealmId = realm.Id,
            DefaultRoles = 
            {
                "uma_authorization",
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-keycloak/sdk/v4/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
		}
		_, err = keycloak.NewDefaultRoles(ctx, "defalutRoles", &keycloak.DefaultRolesArgs{
			RealmId: realm.ID(),
			DefaultRoles: pulumi.StringArray{
				pulumi.String("uma_authorization"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    realm="my-realm",
    enabled=True)
defalut_roles = keycloak.DefaultRoles("defalutRoles",
    realm_id=realm.id,
    default_roles=["uma_authorization"])
import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";

const realm = new keycloak.Realm("realm", {
    realm: "my-realm",
    enabled: true,
});
const defalutRoles = new keycloak.DefaultRoles("defalutRoles", {
    realmId: realm.id,
    defaultRoles: ["uma_authorization"],
});

Create a DefaultRoles Resource

new DefaultRoles(name: string, args: DefaultRolesArgs, opts?: CustomResourceOptions);
@overload
def DefaultRoles(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 default_roles: Optional[Sequence[str]] = None,
                 realm_id: Optional[str] = None)
@overload
def DefaultRoles(resource_name: str,
                 args: DefaultRolesArgs,
                 opts: Optional[ResourceOptions] = None)
func NewDefaultRoles(ctx *Context, name string, args DefaultRolesArgs, opts ...ResourceOption) (*DefaultRoles, error)
public DefaultRoles(string name, DefaultRolesArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args DefaultRolesArgs
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 DefaultRolesArgs
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 DefaultRolesArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args DefaultRolesArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

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

RealmId string
The realm this role exists within.
RoleNames List<string>
Realm level roles assigned to new users by default.
DefaultRoles []string
Realm level roles assigned to new users by default.
RealmId string
The realm this role exists within.
defaultRoles string[]
Realm level roles assigned to new users by default.
realmId string
The realm this role exists within.
default_roles Sequence[str]
Realm level roles assigned to new users by default.
realm_id str
The realm this role exists within.

Outputs

All input properties are implicitly available as output properties. Additionally, the DefaultRoles 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 str
The provider-assigned unique ID for this managed resource.

Look up an Existing DefaultRoles Resource

Get an existing DefaultRoles 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?: DefaultRolesState, opts?: CustomResourceOptions): DefaultRoles
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        default_roles: Optional[Sequence[str]] = None,
        realm_id: Optional[str] = None) -> DefaultRoles
func GetDefaultRoles(ctx *Context, name string, id IDInput, state *DefaultRolesState, opts ...ResourceOption) (*DefaultRoles, error)
public static DefaultRoles Get(string name, Input<string> id, DefaultRolesState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

RealmId string
The realm this role exists within.
RoleNames List<string>
Realm level roles assigned to new users by default.
DefaultRoles []string
Realm level roles assigned to new users by default.
RealmId string
The realm this role exists within.
defaultRoles string[]
Realm level roles assigned to new users by default.
realmId string
The realm this role exists within.
default_roles Sequence[str]
Realm level roles assigned to new users by default.
realm_id str
The realm this role exists within.

Import

Default roles can be imported using the format {{realm_id}}/{{default_role_id}}, where default_role_id is the unique ID of the composite role that Keycloak uses to control default realm level roles. The ID is not easy to find in the GUI, but it appears in the dev tools when editing the default roles. Examplebash

 $ pulumi import keycloak:index/defaultRoles:DefaultRoles default_roles my-realm/a04c35c2-e95a-4dc5-bd32-e83a21be9e7d

Package Details

Repository
https://github.com/pulumi/pulumi-keycloak
License
Apache-2.0
Notes
This Pulumi package is based on the keycloak Terraform Provider.