Keycloak

v4.11.0 published on Thursday, Aug 4, 2022 by Pulumi

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
        {
            RealmName = "my-realm",
            Enabled = true,
        });
        var defaultRoles = new Keycloak.DefaultRoles("defaultRoles", new Keycloak.DefaultRolesArgs
        {
            RealmId = realm.Id,
            RoleNames = 
            {
                "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, "defaultRoles", &keycloak.DefaultRolesArgs{
			RealmId: realm.ID(),
			DefaultRoles: pulumi.StringArray{
				pulumi.String("uma_authorization"),
			},
		})
		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.DefaultRoles;
import com.pulumi.keycloak.DefaultRolesArgs;
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 defaultRoles = new DefaultRoles("defaultRoles", DefaultRolesArgs.builder()        
            .realmId(realm.id())
            .defaultRoles("uma_authorization")
            .build());

    }
}
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    realm="my-realm",
    enabled=True)
default_roles = keycloak.DefaultRoles("defaultRoles",
    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 defaultRoles = new keycloak.DefaultRoles("defaultRoles", {
    realmId: realm.id,
    defaultRoles: ["uma_authorization"],
});
resources:
  realm:
    type: keycloak:Realm
    properties:
      realm: my-realm
      enabled: true
  defaultRoles:
    type: keycloak:DefaultRoles
    properties:
      realmId: ${realm.id}
      defaultRoles:
        - uma_authorization

Create 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)
public DefaultRoles(String name, DefaultRolesArgs args)
public DefaultRoles(String name, DefaultRolesArgs args, CustomResourceOptions options)
type: keycloak:DefaultRoles
properties: # The arguments to resource properties.
options: # 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.
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.
name String
The unique name of the resource.
args DefaultRolesArgs
The arguments to resource properties.
options 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 List<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.

defaultRoles List<String>

Realm level roles assigned to new users by default.

realmId String

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 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 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)
public static DefaultRoles get(String name, Output<String> id, DefaultRolesState 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:
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 List<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.

defaultRoles List<String>

Realm level roles assigned to new users by default.

realmId String

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.