1. Packages
  2. Keycloak Provider
  3. API Docs
  4. CustomIdentityProviderMapping
Keycloak v6.4.0 published on Wednesday, Apr 16, 2025 by Pulumi

keycloak.CustomIdentityProviderMapping

Explore with Pulumi AI

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: "oidc",
    authorizationUrl: "https://example.com/auth",
    tokenUrl: "https://example.com/token",
    clientId: "example_id",
    clientSecret: "example_token",
    defaultScopes: "openid random profile",
});
const oidcCustomIdentityProviderMapping = new keycloak.CustomIdentityProviderMapping("oidc", {
    realm: realm.id,
    name: "email-attribute-importer",
    identityProviderAlias: oidc.alias,
    identityProviderMapper: "%s-user-attribute-idp-mapper",
    extraConfig: {
        syncMode: "INHERIT",
        Claim: "my-email-claim",
        UserAttribute: "email",
    },
});
Copy
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="oidc",
    authorization_url="https://example.com/auth",
    token_url="https://example.com/token",
    client_id="example_id",
    client_secret="example_token",
    default_scopes="openid random profile")
oidc_custom_identity_provider_mapping = keycloak.CustomIdentityProviderMapping("oidc",
    realm=realm.id,
    name="email-attribute-importer",
    identity_provider_alias=oidc.alias,
    identity_provider_mapper="%s-user-attribute-idp-mapper",
    extra_config={
        "syncMode": "INHERIT",
        "Claim": "my-email-claim",
        "UserAttribute": "email",
    })
Copy
package main

import (
	"github.com/pulumi/pulumi-keycloak/sdk/v6/go/keycloak"
	"github.com/pulumi/pulumi-keycloak/sdk/v6/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("oidc"),
			AuthorizationUrl: pulumi.String("https://example.com/auth"),
			TokenUrl:         pulumi.String("https://example.com/token"),
			ClientId:         pulumi.String("example_id"),
			ClientSecret:     pulumi.String("example_token"),
			DefaultScopes:    pulumi.String("openid random profile"),
		})
		if err != nil {
			return err
		}
		_, err = keycloak.NewCustomIdentityProviderMapping(ctx, "oidc", &keycloak.CustomIdentityProviderMappingArgs{
			Realm:                  realm.ID(),
			Name:                   pulumi.String("email-attribute-importer"),
			IdentityProviderAlias:  oidc.Alias,
			IdentityProviderMapper: pulumi.String("%s-user-attribute-idp-mapper"),
			ExtraConfig: pulumi.StringMap{
				"syncMode":      pulumi.String("INHERIT"),
				"Claim":         pulumi.String("my-email-claim"),
				"UserAttribute": pulumi.String("email"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
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 = "oidc",
        AuthorizationUrl = "https://example.com/auth",
        TokenUrl = "https://example.com/token",
        ClientId = "example_id",
        ClientSecret = "example_token",
        DefaultScopes = "openid random profile",
    });

    var oidcCustomIdentityProviderMapping = new Keycloak.CustomIdentityProviderMapping("oidc", new()
    {
        Realm = realm.Id,
        Name = "email-attribute-importer",
        IdentityProviderAlias = oidc.Alias,
        IdentityProviderMapper = "%s-user-attribute-idp-mapper",
        ExtraConfig = 
        {
            { "syncMode", "INHERIT" },
            { "Claim", "my-email-claim" },
            { "UserAttribute", "email" },
        },
    });

});
Copy
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.CustomIdentityProviderMapping;
import com.pulumi.keycloak.CustomIdentityProviderMappingArgs;
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("oidc")
            .authorizationUrl("https://example.com/auth")
            .tokenUrl("https://example.com/token")
            .clientId("example_id")
            .clientSecret("example_token")
            .defaultScopes("openid random profile")
            .build());

        var oidcCustomIdentityProviderMapping = new CustomIdentityProviderMapping("oidcCustomIdentityProviderMapping", CustomIdentityProviderMappingArgs.builder()
            .realm(realm.id())
            .name("email-attribute-importer")
            .identityProviderAlias(oidc.alias())
            .identityProviderMapper("%s-user-attribute-idp-mapper")
            .extraConfig(Map.ofEntries(
                Map.entry("syncMode", "INHERIT"),
                Map.entry("Claim", "my-email-claim"),
                Map.entry("UserAttribute", "email")
            ))
            .build());

    }
}
Copy
resources:
  realm:
    type: keycloak:Realm
    properties:
      realm: my-realm
      enabled: true
  oidc:
    type: keycloak:oidc:IdentityProvider
    properties:
      realm: ${realm.id}
      alias: oidc
      authorizationUrl: https://example.com/auth
      tokenUrl: https://example.com/token
      clientId: example_id
      clientSecret: example_token
      defaultScopes: openid random profile
  oidcCustomIdentityProviderMapping:
    type: keycloak:CustomIdentityProviderMapping
    name: oidc
    properties:
      realm: ${realm.id}
      name: email-attribute-importer
      identityProviderAlias: ${oidc.alias}
      identityProviderMapper: '%s-user-attribute-idp-mapper'
      extraConfig:
        syncMode: INHERIT
        Claim: my-email-claim
        UserAttribute: email
Copy

Create CustomIdentityProviderMapping Resource

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

Constructor syntax

new CustomIdentityProviderMapping(name: string, args: CustomIdentityProviderMappingArgs, opts?: CustomResourceOptions);
@overload
def CustomIdentityProviderMapping(resource_name: str,
                                  args: CustomIdentityProviderMappingArgs,
                                  opts: Optional[ResourceOptions] = None)

@overload
def CustomIdentityProviderMapping(resource_name: str,
                                  opts: Optional[ResourceOptions] = None,
                                  identity_provider_alias: Optional[str] = None,
                                  identity_provider_mapper: Optional[str] = None,
                                  realm: Optional[str] = None,
                                  extra_config: Optional[Mapping[str, str]] = None,
                                  name: Optional[str] = None)
func NewCustomIdentityProviderMapping(ctx *Context, name string, args CustomIdentityProviderMappingArgs, opts ...ResourceOption) (*CustomIdentityProviderMapping, error)
public CustomIdentityProviderMapping(string name, CustomIdentityProviderMappingArgs args, CustomResourceOptions? opts = null)
public CustomIdentityProviderMapping(String name, CustomIdentityProviderMappingArgs args)
public CustomIdentityProviderMapping(String name, CustomIdentityProviderMappingArgs args, CustomResourceOptions options)
type: keycloak:CustomIdentityProviderMapping
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. CustomIdentityProviderMappingArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. CustomIdentityProviderMappingArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. CustomIdentityProviderMappingArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. CustomIdentityProviderMappingArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. CustomIdentityProviderMappingArgs
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 customIdentityProviderMappingResource = new Keycloak.CustomIdentityProviderMapping("customIdentityProviderMappingResource", new()
{
    IdentityProviderAlias = "string",
    IdentityProviderMapper = "string",
    Realm = "string",
    ExtraConfig = 
    {
        { "string", "string" },
    },
    Name = "string",
});
Copy
example, err := keycloak.NewCustomIdentityProviderMapping(ctx, "customIdentityProviderMappingResource", &keycloak.CustomIdentityProviderMappingArgs{
	IdentityProviderAlias:  pulumi.String("string"),
	IdentityProviderMapper: pulumi.String("string"),
	Realm:                  pulumi.String("string"),
	ExtraConfig: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	Name: pulumi.String("string"),
})
Copy
var customIdentityProviderMappingResource = new CustomIdentityProviderMapping("customIdentityProviderMappingResource", CustomIdentityProviderMappingArgs.builder()
    .identityProviderAlias("string")
    .identityProviderMapper("string")
    .realm("string")
    .extraConfig(Map.of("string", "string"))
    .name("string")
    .build());
Copy
custom_identity_provider_mapping_resource = keycloak.CustomIdentityProviderMapping("customIdentityProviderMappingResource",
    identity_provider_alias="string",
    identity_provider_mapper="string",
    realm="string",
    extra_config={
        "string": "string",
    },
    name="string")
Copy
const customIdentityProviderMappingResource = new keycloak.CustomIdentityProviderMapping("customIdentityProviderMappingResource", {
    identityProviderAlias: "string",
    identityProviderMapper: "string",
    realm: "string",
    extraConfig: {
        string: "string",
    },
    name: "string",
});
Copy
type: keycloak:CustomIdentityProviderMapping
properties:
    extraConfig:
        string: string
    identityProviderAlias: string
    identityProviderMapper: string
    name: string
    realm: string
Copy

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

IdentityProviderAlias
This property is required.
Changes to this property will trigger replacement.
string
The alias of the associated identity provider.
IdentityProviderMapper This property is required. string
The type of the identity provider mapper. This can be a format string that includes a %s - this will be replaced by the provider id.
Realm
This property is required.
Changes to this property will trigger replacement.
string
The name of the realm.
ExtraConfig Dictionary<string, string>
Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
Name Changes to this property will trigger replacement. string
The name of the mapper.
IdentityProviderAlias
This property is required.
Changes to this property will trigger replacement.
string
The alias of the associated identity provider.
IdentityProviderMapper This property is required. string
The type of the identity provider mapper. This can be a format string that includes a %s - this will be replaced by the provider id.
Realm
This property is required.
Changes to this property will trigger replacement.
string
The name of the realm.
ExtraConfig map[string]string
Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
Name Changes to this property will trigger replacement. string
The name of the mapper.
identityProviderAlias
This property is required.
Changes to this property will trigger replacement.
String
The alias of the associated identity provider.
identityProviderMapper This property is required. String
The type of the identity provider mapper. This can be a format string that includes a %s - this will be replaced by the provider id.
realm
This property is required.
Changes to this property will trigger replacement.
String
The name of the realm.
extraConfig Map<String,String>
Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
name Changes to this property will trigger replacement. String
The name of the mapper.
identityProviderAlias
This property is required.
Changes to this property will trigger replacement.
string
The alias of the associated identity provider.
identityProviderMapper This property is required. string
The type of the identity provider mapper. This can be a format string that includes a %s - this will be replaced by the provider id.
realm
This property is required.
Changes to this property will trigger replacement.
string
The name of the realm.
extraConfig {[key: string]: string}
Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
name Changes to this property will trigger replacement. string
The name of the mapper.
identity_provider_alias
This property is required.
Changes to this property will trigger replacement.
str
The alias of the associated identity provider.
identity_provider_mapper This property is required. str
The type of the identity provider mapper. This can be a format string that includes a %s - this will be replaced by the provider id.
realm
This property is required.
Changes to this property will trigger replacement.
str
The name of the realm.
extra_config Mapping[str, str]
Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
name Changes to this property will trigger replacement. str
The name of the mapper.
identityProviderAlias
This property is required.
Changes to this property will trigger replacement.
String
The alias of the associated identity provider.
identityProviderMapper This property is required. String
The type of the identity provider mapper. This can be a format string that includes a %s - this will be replaced by the provider id.
realm
This property is required.
Changes to this property will trigger replacement.
String
The name of the realm.
extraConfig Map<String>
Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
name Changes to this property will trigger replacement. String
The name of the mapper.

Outputs

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

Get an existing CustomIdentityProviderMapping 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?: CustomIdentityProviderMappingState, opts?: CustomResourceOptions): CustomIdentityProviderMapping
@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,
        identity_provider_mapper: Optional[str] = None,
        name: Optional[str] = None,
        realm: Optional[str] = None) -> CustomIdentityProviderMapping
func GetCustomIdentityProviderMapping(ctx *Context, name string, id IDInput, state *CustomIdentityProviderMappingState, opts ...ResourceOption) (*CustomIdentityProviderMapping, error)
public static CustomIdentityProviderMapping Get(string name, Input<string> id, CustomIdentityProviderMappingState? state, CustomResourceOptions? opts = null)
public static CustomIdentityProviderMapping get(String name, Output<String> id, CustomIdentityProviderMappingState state, CustomResourceOptions options)
resources:  _:    type: keycloak:CustomIdentityProviderMapping    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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>
Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
IdentityProviderAlias Changes to this property will trigger replacement. string
The alias of the associated identity provider.
IdentityProviderMapper string
The type of the identity provider mapper. This can be a format string that includes a %s - this will be replaced by the provider id.
Name Changes to this property will trigger replacement. string
The name of the mapper.
Realm Changes to this property will trigger replacement. string
The name of the realm.
ExtraConfig map[string]string
Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
IdentityProviderAlias Changes to this property will trigger replacement. string
The alias of the associated identity provider.
IdentityProviderMapper string
The type of the identity provider mapper. This can be a format string that includes a %s - this will be replaced by the provider id.
Name Changes to this property will trigger replacement. string
The name of the mapper.
Realm Changes to this property will trigger replacement. string
The name of the realm.
extraConfig Map<String,String>
Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
identityProviderAlias Changes to this property will trigger replacement. String
The alias of the associated identity provider.
identityProviderMapper String
The type of the identity provider mapper. This can be a format string that includes a %s - this will be replaced by the provider id.
name Changes to this property will trigger replacement. String
The name of the mapper.
realm Changes to this property will trigger replacement. String
The name of the realm.
extraConfig {[key: string]: string}
Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
identityProviderAlias Changes to this property will trigger replacement. string
The alias of the associated identity provider.
identityProviderMapper string
The type of the identity provider mapper. This can be a format string that includes a %s - this will be replaced by the provider id.
name Changes to this property will trigger replacement. string
The name of the mapper.
realm Changes to this property will trigger replacement. string
The name of the realm.
extra_config Mapping[str, str]
Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
identity_provider_alias Changes to this property will trigger replacement. str
The alias of the associated identity provider.
identity_provider_mapper str
The type of the identity provider mapper. This can be a format string that includes a %s - this will be replaced by the provider id.
name Changes to this property will trigger replacement. str
The name of the mapper.
realm Changes to this property will trigger replacement. str
The name of the realm.
extraConfig Map<String>
Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
identityProviderAlias Changes to this property will trigger replacement. String
The alias of the associated identity provider.
identityProviderMapper String
The type of the identity provider mapper. This can be a format string that includes a %s - this will be replaced by the provider id.
name Changes to this property will trigger replacement. String
The name of the mapper.
realm Changes to this property will trigger replacement. String
The name of the realm.

Import

Identity provider mappers can be imported using the format {{realm_id}}/{{idp_alias}}/{{idp_mapper_id}}, where idp_alias is the identity provider alias, and idp_mapper_id is the unique ID that Keycloak

assigns to the mapper upon creation. This value can be found in the URI when editing this mapper in the GUI, and is typically a GUID.

Example:

bash

$ pulumi import keycloak:index/customIdentityProviderMapping:CustomIdentityProviderMapping test_mapper my-realm/my-mapper/f446db98-7133-4e30-b18a-3d28fde7ca1b
Copy

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.