keycloak.AttributeToRoleIdentityMapper
Explore with Pulumi AI
Allows for creating and managing an attribute to role identity provider mapper within Keycloak.
If you are using Keycloak 10 or higher, you will need to specify the
extra_config
argument in order to define asyncMode
for the mapper.
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 realmRole = new keycloak.Role("realm_role", {
realmId: realm.id,
name: "my-realm-role",
description: "My Realm Role",
});
const oidcAttributeToRoleIdentityMapper = new keycloak.AttributeToRoleIdentityMapper("oidc", {
realm: realm.id,
name: "role-attribute",
identityProviderAlias: oidc.alias,
role: "my-realm-role",
claimName: "my-claim",
claimValue: "my-value",
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="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")
realm_role = keycloak.Role("realm_role",
realm_id=realm.id,
name="my-realm-role",
description="My Realm Role")
oidc_attribute_to_role_identity_mapper = keycloak.AttributeToRoleIdentityMapper("oidc",
realm=realm.id,
name="role-attribute",
identity_provider_alias=oidc.alias,
role="my-realm-role",
claim_name="my-claim",
claim_value="my-value",
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("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.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.NewAttributeToRoleIdentityMapper(ctx, "oidc", &keycloak.AttributeToRoleIdentityMapperArgs{
Realm: realm.ID(),
Name: pulumi.String("role-attribute"),
IdentityProviderAlias: oidc.Alias,
Role: pulumi.String("my-realm-role"),
ClaimName: pulumi.String("my-claim"),
ClaimValue: pulumi.String("my-value"),
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 = "oidc",
AuthorizationUrl = "https://example.com/auth",
TokenUrl = "https://example.com/token",
ClientId = "example_id",
ClientSecret = "example_token",
DefaultScopes = "openid random profile",
});
var realmRole = new Keycloak.Role("realm_role", new()
{
RealmId = realm.Id,
Name = "my-realm-role",
Description = "My Realm Role",
});
var oidcAttributeToRoleIdentityMapper = new Keycloak.AttributeToRoleIdentityMapper("oidc", new()
{
Realm = realm.Id,
Name = "role-attribute",
IdentityProviderAlias = oidc.Alias,
Role = "my-realm-role",
ClaimName = "my-claim",
ClaimValue = "my-value",
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.AttributeToRoleIdentityMapper;
import com.pulumi.keycloak.AttributeToRoleIdentityMapperArgs;
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 realmRole = new Role("realmRole", RoleArgs.builder()
.realmId(realm.id())
.name("my-realm-role")
.description("My Realm Role")
.build());
var oidcAttributeToRoleIdentityMapper = new AttributeToRoleIdentityMapper("oidcAttributeToRoleIdentityMapper", AttributeToRoleIdentityMapperArgs.builder()
.realm(realm.id())
.name("role-attribute")
.identityProviderAlias(oidc.alias())
.role("my-realm-role")
.claimName("my-claim")
.claimValue("my-value")
.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: oidc
authorizationUrl: https://example.com/auth
tokenUrl: https://example.com/token
clientId: example_id
clientSecret: example_token
defaultScopes: openid random profile
realmRole:
type: keycloak:Role
name: realm_role
properties:
realmId: ${realm.id}
name: my-realm-role
description: My Realm Role
oidcAttributeToRoleIdentityMapper:
type: keycloak:AttributeToRoleIdentityMapper
name: oidc
properties:
realm: ${realm.id}
name: role-attribute
identityProviderAlias: ${oidc.alias}
role: my-realm-role
claimName: my-claim
claimValue: my-value
extraConfig:
syncMode: INHERIT
Create AttributeToRoleIdentityMapper Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new AttributeToRoleIdentityMapper(name: string, args: AttributeToRoleIdentityMapperArgs, opts?: CustomResourceOptions);
@overload
def AttributeToRoleIdentityMapper(resource_name: str,
args: AttributeToRoleIdentityMapperArgs,
opts: Optional[ResourceOptions] = None)
@overload
def AttributeToRoleIdentityMapper(resource_name: str,
opts: Optional[ResourceOptions] = None,
identity_provider_alias: Optional[str] = None,
realm: Optional[str] = None,
role: Optional[str] = None,
attribute_friendly_name: Optional[str] = None,
attribute_name: Optional[str] = None,
attribute_value: Optional[str] = None,
claim_name: Optional[str] = None,
claim_value: Optional[str] = None,
extra_config: Optional[Mapping[str, str]] = None,
name: Optional[str] = None)
func NewAttributeToRoleIdentityMapper(ctx *Context, name string, args AttributeToRoleIdentityMapperArgs, opts ...ResourceOption) (*AttributeToRoleIdentityMapper, error)
public AttributeToRoleIdentityMapper(string name, AttributeToRoleIdentityMapperArgs args, CustomResourceOptions? opts = null)
public AttributeToRoleIdentityMapper(String name, AttributeToRoleIdentityMapperArgs args)
public AttributeToRoleIdentityMapper(String name, AttributeToRoleIdentityMapperArgs args, CustomResourceOptions options)
type: keycloak:AttributeToRoleIdentityMapper
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 AttributeToRoleIdentityMapperArgs
- 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 AttributeToRoleIdentityMapperArgs
- 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 AttributeToRoleIdentityMapperArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args AttributeToRoleIdentityMapperArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args AttributeToRoleIdentityMapperArgs
- 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 attributeToRoleIdentityMapperResource = new Keycloak.AttributeToRoleIdentityMapper("attributeToRoleIdentityMapperResource", new()
{
IdentityProviderAlias = "string",
Realm = "string",
Role = "string",
AttributeFriendlyName = "string",
AttributeName = "string",
AttributeValue = "string",
ClaimName = "string",
ClaimValue = "string",
ExtraConfig =
{
{ "string", "string" },
},
Name = "string",
});
example, err := keycloak.NewAttributeToRoleIdentityMapper(ctx, "attributeToRoleIdentityMapperResource", &keycloak.AttributeToRoleIdentityMapperArgs{
IdentityProviderAlias: pulumi.String("string"),
Realm: pulumi.String("string"),
Role: pulumi.String("string"),
AttributeFriendlyName: pulumi.String("string"),
AttributeName: pulumi.String("string"),
AttributeValue: pulumi.String("string"),
ClaimName: pulumi.String("string"),
ClaimValue: pulumi.String("string"),
ExtraConfig: pulumi.StringMap{
"string": pulumi.String("string"),
},
Name: pulumi.String("string"),
})
var attributeToRoleIdentityMapperResource = new AttributeToRoleIdentityMapper("attributeToRoleIdentityMapperResource", AttributeToRoleIdentityMapperArgs.builder()
.identityProviderAlias("string")
.realm("string")
.role("string")
.attributeFriendlyName("string")
.attributeName("string")
.attributeValue("string")
.claimName("string")
.claimValue("string")
.extraConfig(Map.of("string", "string"))
.name("string")
.build());
attribute_to_role_identity_mapper_resource = keycloak.AttributeToRoleIdentityMapper("attributeToRoleIdentityMapperResource",
identity_provider_alias="string",
realm="string",
role="string",
attribute_friendly_name="string",
attribute_name="string",
attribute_value="string",
claim_name="string",
claim_value="string",
extra_config={
"string": "string",
},
name="string")
const attributeToRoleIdentityMapperResource = new keycloak.AttributeToRoleIdentityMapper("attributeToRoleIdentityMapperResource", {
identityProviderAlias: "string",
realm: "string",
role: "string",
attributeFriendlyName: "string",
attributeName: "string",
attributeValue: "string",
claimName: "string",
claimValue: "string",
extraConfig: {
string: "string",
},
name: "string",
});
type: keycloak:AttributeToRoleIdentityMapper
properties:
attributeFriendlyName: string
attributeName: string
attributeValue: string
claimName: string
claimValue: string
extraConfig:
string: string
identityProviderAlias: string
name: string
realm: string
role: string
AttributeToRoleIdentityMapper 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 AttributeToRoleIdentityMapper resource accepts the following input properties:
- Identity
Provider stringAlias - The alias of the associated identity provider.
- Realm string
- The name of the realm.
- Role string
- Role Name.
- Attribute
Friendly stringName - Attribute Friendly Name. Conflicts with
attribute_name
. - Attribute
Name string - Attribute Name.
- Attribute
Value string - Attribute Value.
- Claim
Name string - OIDC Claim Name
- Claim
Value string - OIDC Claim Value
- Extra
Config 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 string
- The name of the mapper.
- Identity
Provider stringAlias - The alias of the associated identity provider.
- Realm string
- The name of the realm.
- Role string
- Role Name.
- Attribute
Friendly stringName - Attribute Friendly Name. Conflicts with
attribute_name
. - Attribute
Name string - Attribute Name.
- Attribute
Value string - Attribute Value.
- Claim
Name string - OIDC Claim Name
- Claim
Value string - OIDC Claim Value
- Extra
Config 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 string
- The name of the mapper.
- identity
Provider StringAlias - The alias of the associated identity provider.
- realm String
- The name of the realm.
- role String
- Role Name.
- attribute
Friendly StringName - Attribute Friendly Name. Conflicts with
attribute_name
. - attribute
Name String - Attribute Name.
- attribute
Value String - Attribute Value.
- claim
Name String - OIDC Claim Name
- claim
Value String - OIDC Claim Value
- extra
Config 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 String
- The name of the mapper.
- identity
Provider stringAlias - The alias of the associated identity provider.
- realm string
- The name of the realm.
- role string
- Role Name.
- attribute
Friendly stringName - Attribute Friendly Name. Conflicts with
attribute_name
. - attribute
Name string - Attribute Name.
- attribute
Value string - Attribute Value.
- claim
Name string - OIDC Claim Name
- claim
Value string - OIDC Claim Value
- extra
Config {[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 string
- The name of the mapper.
- identity_
provider_ stralias - The alias of the associated identity provider.
- realm str
- The name of the realm.
- role str
- Role Name.
- attribute_
friendly_ strname - Attribute Friendly Name. Conflicts with
attribute_name
. - attribute_
name str - Attribute Name.
- attribute_
value str - Attribute Value.
- claim_
name str - OIDC Claim Name
- claim_
value str - OIDC Claim Value
- 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 str
- The name of the mapper.
- identity
Provider StringAlias - The alias of the associated identity provider.
- realm String
- The name of the realm.
- role String
- Role Name.
- attribute
Friendly StringName - Attribute Friendly Name. Conflicts with
attribute_name
. - attribute
Name String - Attribute Name.
- attribute
Value String - Attribute Value.
- claim
Name String - OIDC Claim Name
- claim
Value String - OIDC Claim Value
- extra
Config 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 String
- The name of the mapper.
Outputs
All input properties are implicitly available as output properties. Additionally, the AttributeToRoleIdentityMapper 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 AttributeToRoleIdentityMapper Resource
Get an existing AttributeToRoleIdentityMapper 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?: AttributeToRoleIdentityMapperState, opts?: CustomResourceOptions): AttributeToRoleIdentityMapper
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
attribute_friendly_name: Optional[str] = None,
attribute_name: Optional[str] = None,
attribute_value: Optional[str] = None,
claim_name: Optional[str] = None,
claim_value: Optional[str] = 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) -> AttributeToRoleIdentityMapper
func GetAttributeToRoleIdentityMapper(ctx *Context, name string, id IDInput, state *AttributeToRoleIdentityMapperState, opts ...ResourceOption) (*AttributeToRoleIdentityMapper, error)
public static AttributeToRoleIdentityMapper Get(string name, Input<string> id, AttributeToRoleIdentityMapperState? state, CustomResourceOptions? opts = null)
public static AttributeToRoleIdentityMapper get(String name, Output<String> id, AttributeToRoleIdentityMapperState 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.
- Attribute
Friendly stringName - Attribute Friendly Name. Conflicts with
attribute_name
. - Attribute
Name string - Attribute Name.
- Attribute
Value string - Attribute Value.
- Claim
Name string - OIDC Claim Name
- Claim
Value string - OIDC Claim Value
- Extra
Config 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.
- Identity
Provider stringAlias - The alias of the associated identity provider.
- Name string
- The name of the mapper.
- Realm string
- The name of the realm.
- Role string
- Role Name.
- Attribute
Friendly stringName - Attribute Friendly Name. Conflicts with
attribute_name
. - Attribute
Name string - Attribute Name.
- Attribute
Value string - Attribute Value.
- Claim
Name string - OIDC Claim Name
- Claim
Value string - OIDC Claim Value
- Extra
Config 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.
- Identity
Provider stringAlias - The alias of the associated identity provider.
- Name string
- The name of the mapper.
- Realm string
- The name of the realm.
- Role string
- Role Name.
- attribute
Friendly StringName - Attribute Friendly Name. Conflicts with
attribute_name
. - attribute
Name String - Attribute Name.
- attribute
Value String - Attribute Value.
- claim
Name String - OIDC Claim Name
- claim
Value String - OIDC Claim Value
- extra
Config 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.
- identity
Provider StringAlias - The alias of the associated identity provider.
- name String
- The name of the mapper.
- realm String
- The name of the realm.
- role String
- Role Name.
- attribute
Friendly stringName - Attribute Friendly Name. Conflicts with
attribute_name
. - attribute
Name string - Attribute Name.
- attribute
Value string - Attribute Value.
- claim
Name string - OIDC Claim Name
- claim
Value string - OIDC Claim Value
- extra
Config {[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.
- identity
Provider stringAlias - The alias of the associated identity provider.
- name string
- The name of the mapper.
- realm string
- The name of the realm.
- role string
- Role Name.
- attribute_
friendly_ strname - Attribute Friendly Name. Conflicts with
attribute_name
. - attribute_
name str - Attribute Name.
- attribute_
value str - Attribute Value.
- claim_
name str - OIDC Claim Name
- claim_
value str - OIDC Claim Value
- 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_ stralias - The alias of the associated identity provider.
- name str
- The name of the mapper.
- realm str
- The name of the realm.
- role str
- Role Name.
- attribute
Friendly StringName - Attribute Friendly Name. Conflicts with
attribute_name
. - attribute
Name String - Attribute Name.
- attribute
Value String - Attribute Value.
- claim
Name String - OIDC Claim Name
- claim
Value String - OIDC Claim Value
- extra
Config 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.
- identity
Provider StringAlias - The alias of the associated identity provider.
- name String
- The name of the mapper.
- realm String
- The name of the realm.
- role String
- Role Name.
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/attributeToRoleIdentityMapper:AttributeToRoleIdentityMapper test_mapper my-realm/my-mapper/f446db98-7133-4e30-b18a-3d28fde7ca1b
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.