1. Packages
  2. Keycloak Provider
  3. API Docs
  4. HardcodedRoleIdentityMapper
Keycloak v5.4.0 published on Monday, Dec 9, 2024 by Pulumi

keycloak.HardcodedRoleIdentityMapper

Explore with Pulumi AI

keycloak logo
Keycloak v5.4.0 published on Monday, Dec 9, 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 oidc = new keycloak.oidc.IdentityProvider("oidc", {
        realm: realm.id,
        alias: "my-idp",
        authorizationUrl: "https://authorizationurl.com",
        clientId: "clientID",
        clientSecret: "clientSecret",
        tokenUrl: "https://tokenurl.com",
    });
    const realmRole = new keycloak.Role("realm_role", {
        realmId: realm.id,
        name: "my-realm-role",
        description: "My Realm Role",
    });
    const oidcHardcodedRoleIdentityMapper = new keycloak.HardcodedRoleIdentityMapper("oidc", {
        realm: realm.id,
        name: "hardcodedRole",
        identityProviderAlias: oidc.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 = keycloak.oidc.IdentityProvider("oidc",
        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("realm_role",
        realm_id=realm.id,
        name="my-realm-role",
        description="My Realm Role")
    oidc_hardcoded_role_identity_mapper = keycloak.HardcodedRoleIdentityMapper("oidc",
        realm=realm.id,
        name="hardcodedRole",
        identity_provider_alias=oidc.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
    		}
    		oidc, err := oidc.NewIdentityProvider(ctx, "oidc", &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, "realm_role", &keycloak.RoleArgs{
    			RealmId:     realm.ID(),
    			Name:        pulumi.String("my-realm-role"),
    			Description: pulumi.String("My Realm Role"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewHardcodedRoleIdentityMapper(ctx, "oidc", &keycloak.HardcodedRoleIdentityMapperArgs{
    			Realm:                 realm.ID(),
    			Name:                  pulumi.String("hardcodedRole"),
    			IdentityProviderAlias: oidc.Alias,
    			Role:                  pulumi.String("my-realm-role"),
    			ExtraConfig: pulumi.StringMap{
    				"syncMode": pulumi.String("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 oidc = new Keycloak.Oidc.IdentityProvider("oidc", new()
        {
            Realm = realm.Id,
            Alias = "my-idp",
            AuthorizationUrl = "https://authorizationurl.com",
            ClientId = "clientID",
            ClientSecret = "clientSecret",
            TokenUrl = "https://tokenurl.com",
        });
    
        var realmRole = new Keycloak.Role("realm_role", new()
        {
            RealmId = realm.Id,
            Name = "my-realm-role",
            Description = "My Realm Role",
        });
    
        var oidcHardcodedRoleIdentityMapper = new Keycloak.HardcodedRoleIdentityMapper("oidc", new()
        {
            Realm = realm.Id,
            Name = "hardcodedRole",
            IdentityProviderAlias = oidc.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 oidc = new IdentityProvider("oidc", 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())
                .name("my-realm-role")
                .description("My Realm Role")
                .build());
    
            var oidcHardcodedRoleIdentityMapper = new HardcodedRoleIdentityMapper("oidcHardcodedRoleIdentityMapper", HardcodedRoleIdentityMapperArgs.builder()
                .realm(realm.id())
                .name("hardcodedRole")
                .identityProviderAlias(oidc.alias())
                .role("my-realm-role")
                .extraConfig(Map.of("syncMode", "INHERIT"))
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      oidc:
        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
        name: realm_role
        properties:
          realmId: ${realm.id}
          name: my-realm-role
          description: My Realm Role
      oidcHardcodedRoleIdentityMapper:
        type: keycloak:HardcodedRoleIdentityMapper
        name: oidc
        properties:
          realm: ${realm.id}
          name: hardcodedRole
          identityProviderAlias: ${oidc.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, str]] = 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.

    Constructor 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", "string" },
        },
        Name = "string",
        Role = "string",
    });
    
    example, err := keycloak.NewHardcodedRoleIdentityMapper(ctx, "hardcodedRoleIdentityMapperResource", &keycloak.HardcodedRoleIdentityMapperArgs{
    	IdentityProviderAlias: pulumi.String("string"),
    	Realm:                 pulumi.String("string"),
    	ExtraConfig: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	Name: pulumi.String("string"),
    	Role: pulumi.String("string"),
    })
    
    var hardcodedRoleIdentityMapperResource = new HardcodedRoleIdentityMapper("hardcodedRoleIdentityMapperResource", HardcodedRoleIdentityMapperArgs.builder()
        .identityProviderAlias("string")
        .realm("string")
        .extraConfig(Map.of("string", "string"))
        .name("string")
        .role("string")
        .build());
    
    hardcoded_role_identity_mapper_resource = keycloak.HardcodedRoleIdentityMapper("hardcodedRoleIdentityMapperResource",
        identity_provider_alias="string",
        realm="string",
        extra_config={
            "string": "string",
        },
        name="string",
        role="string")
    
    const hardcodedRoleIdentityMapperResource = new keycloak.HardcodedRoleIdentityMapper("hardcodedRoleIdentityMapperResource", {
        identityProviderAlias: "string",
        realm: "string",
        extraConfig: {
            string: "string",
        },
        name: "string",
        role: "string",
    });
    
    type: keycloak:HardcodedRoleIdentityMapper
    properties:
        extraConfig:
            string: string
        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

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

    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, string>
    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]string
    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,String>
    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]: string}
    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, str]
    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<String>
    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, str]] = 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, string>
    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]string
    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,String>
    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]: string}
    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, str]
    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<String>
    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.4.0 published on Monday, Dec 9, 2024 by Pulumi