1. Packages
  2. Keycloak
  3. API Docs
  4. HardcodedRoleIdentityMapper
Keycloak v5.3.1 published on Monday, Mar 11, 2024 by Pulumi

keycloak.HardcodedRoleIdentityMapper

Explore with Pulumi AI

keycloak logo
Keycloak v5.3.1 published on Monday, Mar 11, 2024 by Pulumi

    Allows for creating and managing hardcoded role mappers for Keycloak identity provider.

    The identity provider hardcoded role mapper grants a specified Keycloak role to each Keycloak user from the LDAP provider.

    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 oidcIdentityProvider = new keycloak.oidc.IdentityProvider("oidcIdentityProvider", {
        realm: realm.id,
        alias: "my-idp",
        authorizationUrl: "https://authorizationurl.com",
        clientId: "clientID",
        clientSecret: "clientSecret",
        tokenUrl: "https://tokenurl.com",
    });
    const realmRole = new keycloak.Role("realmRole", {
        realmId: realm.id,
        description: "My Realm Role",
    });
    const oidcHardcodedRoleIdentityMapper = new keycloak.HardcodedRoleIdentityMapper("oidcHardcodedRoleIdentityMapper", {
        realm: realm.id,
        identityProviderAlias: oidcIdentityProvider.alias,
        role: "my-realm-role",
        extraConfig: {
            syncMode: "INHERIT",
        },
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    oidc_identity_provider = keycloak.oidc.IdentityProvider("oidcIdentityProvider",
        realm=realm.id,
        alias="my-idp",
        authorization_url="https://authorizationurl.com",
        client_id="clientID",
        client_secret="clientSecret",
        token_url="https://tokenurl.com")
    realm_role = keycloak.Role("realmRole",
        realm_id=realm.id,
        description="My Realm Role")
    oidc_hardcoded_role_identity_mapper = keycloak.HardcodedRoleIdentityMapper("oidcHardcodedRoleIdentityMapper",
        realm=realm.id,
        identity_provider_alias=oidc_identity_provider.alias,
        role="my-realm-role",
        extra_config={
            "syncMode": "INHERIT",
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak/oidc"
    	"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
    		}
    		oidcIdentityProvider, err := oidc.NewIdentityProvider(ctx, "oidcIdentityProvider", &oidc.IdentityProviderArgs{
    			Realm:            realm.ID(),
    			Alias:            pulumi.String("my-idp"),
    			AuthorizationUrl: pulumi.String("https://authorizationurl.com"),
    			ClientId:         pulumi.String("clientID"),
    			ClientSecret:     pulumi.String("clientSecret"),
    			TokenUrl:         pulumi.String("https://tokenurl.com"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewRole(ctx, "realmRole", &keycloak.RoleArgs{
    			RealmId:     realm.ID(),
    			Description: pulumi.String("My Realm Role"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewHardcodedRoleIdentityMapper(ctx, "oidcHardcodedRoleIdentityMapper", &keycloak.HardcodedRoleIdentityMapperArgs{
    			Realm:                 realm.ID(),
    			IdentityProviderAlias: oidcIdentityProvider.Alias,
    			Role:                  pulumi.String("my-realm-role"),
    			ExtraConfig: pulumi.Map{
    				"syncMode": pulumi.Any("INHERIT"),
    			},
    		})
    		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 oidcIdentityProvider = new Keycloak.Oidc.IdentityProvider("oidcIdentityProvider", new()
        {
            Realm = realm.Id,
            Alias = "my-idp",
            AuthorizationUrl = "https://authorizationurl.com",
            ClientId = "clientID",
            ClientSecret = "clientSecret",
            TokenUrl = "https://tokenurl.com",
        });
    
        var realmRole = new Keycloak.Role("realmRole", new()
        {
            RealmId = realm.Id,
            Description = "My Realm Role",
        });
    
        var oidcHardcodedRoleIdentityMapper = new Keycloak.HardcodedRoleIdentityMapper("oidcHardcodedRoleIdentityMapper", new()
        {
            Realm = realm.Id,
            IdentityProviderAlias = oidcIdentityProvider.Alias,
            Role = "my-realm-role",
            ExtraConfig = 
            {
                { "syncMode", "INHERIT" },
            },
        });
    
    });
    
    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.oidc.IdentityProvider;
    import com.pulumi.keycloak.oidc.IdentityProviderArgs;
    import com.pulumi.keycloak.Role;
    import com.pulumi.keycloak.RoleArgs;
    import com.pulumi.keycloak.HardcodedRoleIdentityMapper;
    import com.pulumi.keycloak.HardcodedRoleIdentityMapperArgs;
    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 oidcIdentityProvider = new IdentityProvider("oidcIdentityProvider", IdentityProviderArgs.builder()        
                .realm(realm.id())
                .alias("my-idp")
                .authorizationUrl("https://authorizationurl.com")
                .clientId("clientID")
                .clientSecret("clientSecret")
                .tokenUrl("https://tokenurl.com")
                .build());
    
            var realmRole = new Role("realmRole", RoleArgs.builder()        
                .realmId(realm.id())
                .description("My Realm Role")
                .build());
    
            var oidcHardcodedRoleIdentityMapper = new HardcodedRoleIdentityMapper("oidcHardcodedRoleIdentityMapper", HardcodedRoleIdentityMapperArgs.builder()        
                .realm(realm.id())
                .identityProviderAlias(oidcIdentityProvider.alias())
                .role("my-realm-role")
                .extraConfig(Map.of("syncMode", "INHERIT"))
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      oidcIdentityProvider:
        type: keycloak:oidc:IdentityProvider
        properties:
          realm: ${realm.id}
          alias: my-idp
          authorizationUrl: https://authorizationurl.com
          clientId: clientID
          clientSecret: clientSecret
          tokenUrl: https://tokenurl.com
      realmRole:
        type: keycloak:Role
        properties:
          realmId: ${realm.id}
          description: My Realm Role
      oidcHardcodedRoleIdentityMapper:
        type: keycloak:HardcodedRoleIdentityMapper
        properties:
          realm: ${realm.id}
          identityProviderAlias: ${oidcIdentityProvider.alias}
          role: my-realm-role
          extraConfig:
            syncMode: INHERIT
    

    Create HardcodedRoleIdentityMapper Resource

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

    Constructor syntax

    new HardcodedRoleIdentityMapper(name: string, args: HardcodedRoleIdentityMapperArgs, opts?: CustomResourceOptions);
    @overload
    def HardcodedRoleIdentityMapper(resource_name: str,
                                    args: HardcodedRoleIdentityMapperArgs,
                                    opts: Optional[ResourceOptions] = None)
    
    @overload
    def HardcodedRoleIdentityMapper(resource_name: str,
                                    opts: Optional[ResourceOptions] = None,
                                    identity_provider_alias: Optional[str] = None,
                                    realm: Optional[str] = None,
                                    extra_config: Optional[Mapping[str, Any]] = None,
                                    name: Optional[str] = None,
                                    role: Optional[str] = None)
    func NewHardcodedRoleIdentityMapper(ctx *Context, name string, args HardcodedRoleIdentityMapperArgs, opts ...ResourceOption) (*HardcodedRoleIdentityMapper, error)
    public HardcodedRoleIdentityMapper(string name, HardcodedRoleIdentityMapperArgs args, CustomResourceOptions? opts = null)
    public HardcodedRoleIdentityMapper(String name, HardcodedRoleIdentityMapperArgs args)
    public HardcodedRoleIdentityMapper(String name, HardcodedRoleIdentityMapperArgs args, CustomResourceOptions options)
    
    type: keycloak:HardcodedRoleIdentityMapper
    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 HardcodedRoleIdentityMapperArgs
    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 HardcodedRoleIdentityMapperArgs
    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 HardcodedRoleIdentityMapperArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args HardcodedRoleIdentityMapperArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args HardcodedRoleIdentityMapperArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

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

    var hardcodedRoleIdentityMapperResource = new Keycloak.HardcodedRoleIdentityMapper("hardcodedRoleIdentityMapperResource", new()
    {
        IdentityProviderAlias = "string",
        Realm = "string",
        ExtraConfig = 
        {
            { "string", "any" },
        },
        Name = "string",
        Role = "string",
    });
    
    example, err := keycloak.NewHardcodedRoleIdentityMapper(ctx, "hardcodedRoleIdentityMapperResource", &keycloak.HardcodedRoleIdentityMapperArgs{
    	IdentityProviderAlias: pulumi.String("string"),
    	Realm:                 pulumi.String("string"),
    	ExtraConfig: pulumi.Map{
    		"string": pulumi.Any("any"),
    	},
    	Name: pulumi.String("string"),
    	Role: pulumi.String("string"),
    })
    
    var hardcodedRoleIdentityMapperResource = new HardcodedRoleIdentityMapper("hardcodedRoleIdentityMapperResource", HardcodedRoleIdentityMapperArgs.builder()        
        .identityProviderAlias("string")
        .realm("string")
        .extraConfig(Map.of("string", "any"))
        .name("string")
        .role("string")
        .build());
    
    hardcoded_role_identity_mapper_resource = keycloak.HardcodedRoleIdentityMapper("hardcodedRoleIdentityMapperResource",
        identity_provider_alias="string",
        realm="string",
        extra_config={
            "string": "any",
        },
        name="string",
        role="string")
    
    const hardcodedRoleIdentityMapperResource = new keycloak.HardcodedRoleIdentityMapper("hardcodedRoleIdentityMapperResource", {
        identityProviderAlias: "string",
        realm: "string",
        extraConfig: {
            string: "any",
        },
        name: "string",
        role: "string",
    });
    
    type: keycloak:HardcodedRoleIdentityMapper
    properties:
        extraConfig:
            string: any
        identityProviderAlias: string
        name: string
        realm: string
        role: string
    

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

    IdentityProviderAlias string
    The IDP alias of the attribute to set.
    Realm string
    The realm ID that this mapper will exist in.
    ExtraConfig Dictionary<string, object>
    Name string
    Display name of this mapper when displayed in the console.
    Role string
    The name of the role which should be assigned to the users.
    IdentityProviderAlias string
    The IDP alias of the attribute to set.
    Realm string
    The realm ID that this mapper will exist in.
    ExtraConfig map[string]interface{}
    Name string
    Display name of this mapper when displayed in the console.
    Role string
    The name of the role which should be assigned to the users.
    identityProviderAlias String
    The IDP alias of the attribute to set.
    realm String
    The realm ID that this mapper will exist in.
    extraConfig Map<String,Object>
    name String
    Display name of this mapper when displayed in the console.
    role String
    The name of the role which should be assigned to the users.
    identityProviderAlias string
    The IDP alias of the attribute to set.
    realm string
    The realm ID that this mapper will exist in.
    extraConfig {[key: string]: any}
    name string
    Display name of this mapper when displayed in the console.
    role string
    The name of the role which should be assigned to the users.
    identity_provider_alias str
    The IDP alias of the attribute to set.
    realm str
    The realm ID that this mapper will exist in.
    extra_config Mapping[str, Any]
    name str
    Display name of this mapper when displayed in the console.
    role str
    The name of the role which should be assigned to the users.
    identityProviderAlias String
    The IDP alias of the attribute to set.
    realm String
    The realm ID that this mapper will exist in.
    extraConfig Map<Any>
    name String
    Display name of this mapper when displayed in the console.
    role String
    The name of the role which should be assigned to the users.

    Outputs

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

    Get an existing HardcodedRoleIdentityMapper 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?: HardcodedRoleIdentityMapperState, opts?: CustomResourceOptions): HardcodedRoleIdentityMapper
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            extra_config: Optional[Mapping[str, Any]] = None,
            identity_provider_alias: Optional[str] = None,
            name: Optional[str] = None,
            realm: Optional[str] = None,
            role: Optional[str] = None) -> HardcodedRoleIdentityMapper
    func GetHardcodedRoleIdentityMapper(ctx *Context, name string, id IDInput, state *HardcodedRoleIdentityMapperState, opts ...ResourceOption) (*HardcodedRoleIdentityMapper, error)
    public static HardcodedRoleIdentityMapper Get(string name, Input<string> id, HardcodedRoleIdentityMapperState? state, CustomResourceOptions? opts = null)
    public static HardcodedRoleIdentityMapper get(String name, Output<String> id, HardcodedRoleIdentityMapperState 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:
    ExtraConfig Dictionary<string, object>
    IdentityProviderAlias string
    The IDP alias of the attribute to set.
    Name string
    Display name of this mapper when displayed in the console.
    Realm string
    The realm ID that this mapper will exist in.
    Role string
    The name of the role which should be assigned to the users.
    ExtraConfig map[string]interface{}
    IdentityProviderAlias string
    The IDP alias of the attribute to set.
    Name string
    Display name of this mapper when displayed in the console.
    Realm string
    The realm ID that this mapper will exist in.
    Role string
    The name of the role which should be assigned to the users.
    extraConfig Map<String,Object>
    identityProviderAlias String
    The IDP alias of the attribute to set.
    name String
    Display name of this mapper when displayed in the console.
    realm String
    The realm ID that this mapper will exist in.
    role String
    The name of the role which should be assigned to the users.
    extraConfig {[key: string]: any}
    identityProviderAlias string
    The IDP alias of the attribute to set.
    name string
    Display name of this mapper when displayed in the console.
    realm string
    The realm ID that this mapper will exist in.
    role string
    The name of the role which should be assigned to the users.
    extra_config Mapping[str, Any]
    identity_provider_alias str
    The IDP alias of the attribute to set.
    name str
    Display name of this mapper when displayed in the console.
    realm str
    The realm ID that this mapper will exist in.
    role str
    The name of the role which should be assigned to the users.
    extraConfig Map<Any>
    identityProviderAlias String
    The IDP alias of the attribute to set.
    name String
    Display name of this mapper when displayed in the console.
    realm String
    The realm ID that this mapper will exist in.
    role String
    The name of the role which should be assigned to the users.

    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.1 published on Monday, Mar 11, 2024 by Pulumi