1. Packages
  2. Keycloak Provider
  3. API Docs
  4. DefaultRoles
Keycloak v5.3.5 published on Wednesday, Oct 16, 2024 by Pulumi

keycloak.DefaultRoles

Explore with Pulumi AI

keycloak logo
Keycloak v5.3.5 published on Wednesday, Oct 16, 2024 by Pulumi

    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)

    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("default_roles", {
        realmId: realm.id,
        defaultRoles: ["uma_authorization"],
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    default_roles = keycloak.DefaultRoles("default_roles",
        realm_id=realm.id,
        default_roles=["uma_authorization"])
    
    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
    		}
    		_, err = keycloak.NewDefaultRoles(ctx, "default_roles", &keycloak.DefaultRolesArgs{
    			RealmId: realm.ID(),
    			DefaultRoles: pulumi.StringArray{
    				pulumi.String("uma_authorization"),
    			},
    		})
    		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 defaultRoles = new Keycloak.DefaultRoles("default_roles", new()
        {
            RealmId = realm.Id,
            RoleNames = new[]
            {
                "uma_authorization",
            },
        });
    
    });
    
    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());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      defaultRoles:
        type: keycloak:DefaultRoles
        name: default_roles
        properties:
          realmId: ${realm.id}
          defaultRoles:
            - uma_authorization
    

    Create DefaultRoles Resource

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

    Constructor syntax

    new DefaultRoles(name: string, args: DefaultRolesArgs, opts?: CustomResourceOptions);
    @overload
    def DefaultRoles(resource_name: str,
                     args: DefaultRolesArgs,
                     opts: Optional[ResourceOptions] = None)
    
    @overload
    def DefaultRoles(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     default_roles: Optional[Sequence[str]] = None,
                     realm_id: Optional[str] = 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.
    
    

    Parameters

    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.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var defaultRolesResource = new Keycloak.DefaultRoles("defaultRolesResource", new()
    {
        RoleNames = new[]
        {
            "string",
        },
        RealmId = "string",
    });
    
    example, err := keycloak.NewDefaultRoles(ctx, "defaultRolesResource", &keycloak.DefaultRolesArgs{
    	DefaultRoles: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	RealmId: pulumi.String("string"),
    })
    
    var defaultRolesResource = new DefaultRoles("defaultRolesResource", DefaultRolesArgs.builder()
        .defaultRoles("string")
        .realmId("string")
        .build());
    
    default_roles_resource = keycloak.DefaultRoles("defaultRolesResource",
        default_roles=["string"],
        realm_id="string")
    
    const defaultRolesResource = new keycloak.DefaultRoles("defaultRolesResource", {
        defaultRoles: ["string"],
        realmId: "string",
    });
    
    type: keycloak:DefaultRoles
    properties:
        defaultRoles:
            - string
        realmId: string
    

    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

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    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.

    Example:

    bash

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

    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 v5.3.5 published on Wednesday, Oct 16, 2024 by Pulumi