keycloak.ldap.HardcodedAttributeMapper
Explore with Pulumi AI
Allows for creating and managing hardcoded attribute mappers for Keycloak users federated via LDAP.
The LDAP hardcoded attribute mapper will set the specified value to the LDAP attribute.
NOTE: This mapper only works when the sync_registrations
attribute on the keycloak.ldap.UserFederation
resource is set to true
.
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 ldapUserFederation = new keycloak.ldap.UserFederation("ldap_user_federation", {
name: "openldap",
realmId: realm.id,
usernameLdapAttribute: "cn",
rdnLdapAttribute: "cn",
uuidLdapAttribute: "entryDN",
userObjectClasses: [
"simpleSecurityObject",
"organizationalRole",
],
connectionUrl: "ldap://openldap",
usersDn: "dc=example,dc=org",
bindDn: "cn=admin,dc=example,dc=org",
bindCredential: "admin",
syncRegistrations: true,
});
const assignBarToFoo = new keycloak.ldap.HardcodedAttributeMapper("assign_bar_to_foo", {
realmId: realm.id,
ldapUserFederationId: ldapUserFederation.id,
name: "assign-foo-to-bar",
attributeName: "foo",
attributeValue: "bar",
});
import pulumi
import pulumi_keycloak as keycloak
realm = keycloak.Realm("realm",
realm="my-realm",
enabled=True)
ldap_user_federation = keycloak.ldap.UserFederation("ldap_user_federation",
name="openldap",
realm_id=realm.id,
username_ldap_attribute="cn",
rdn_ldap_attribute="cn",
uuid_ldap_attribute="entryDN",
user_object_classes=[
"simpleSecurityObject",
"organizationalRole",
],
connection_url="ldap://openldap",
users_dn="dc=example,dc=org",
bind_dn="cn=admin,dc=example,dc=org",
bind_credential="admin",
sync_registrations=True)
assign_bar_to_foo = keycloak.ldap.HardcodedAttributeMapper("assign_bar_to_foo",
realm_id=realm.id,
ldap_user_federation_id=ldap_user_federation.id,
name="assign-foo-to-bar",
attribute_name="foo",
attribute_value="bar")
package main
import (
"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak/ldap"
"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
}
ldapUserFederation, err := ldap.NewUserFederation(ctx, "ldap_user_federation", &ldap.UserFederationArgs{
Name: pulumi.String("openldap"),
RealmId: realm.ID(),
UsernameLdapAttribute: pulumi.String("cn"),
RdnLdapAttribute: pulumi.String("cn"),
UuidLdapAttribute: pulumi.String("entryDN"),
UserObjectClasses: pulumi.StringArray{
pulumi.String("simpleSecurityObject"),
pulumi.String("organizationalRole"),
},
ConnectionUrl: pulumi.String("ldap://openldap"),
UsersDn: pulumi.String("dc=example,dc=org"),
BindDn: pulumi.String("cn=admin,dc=example,dc=org"),
BindCredential: pulumi.String("admin"),
SyncRegistrations: pulumi.Bool(true),
})
if err != nil {
return err
}
_, err = ldap.NewHardcodedAttributeMapper(ctx, "assign_bar_to_foo", &ldap.HardcodedAttributeMapperArgs{
RealmId: realm.ID(),
LdapUserFederationId: ldapUserFederation.ID(),
Name: pulumi.String("assign-foo-to-bar"),
AttributeName: pulumi.String("foo"),
AttributeValue: pulumi.String("bar"),
})
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 ldapUserFederation = new Keycloak.Ldap.UserFederation("ldap_user_federation", new()
{
Name = "openldap",
RealmId = realm.Id,
UsernameLdapAttribute = "cn",
RdnLdapAttribute = "cn",
UuidLdapAttribute = "entryDN",
UserObjectClasses = new[]
{
"simpleSecurityObject",
"organizationalRole",
},
ConnectionUrl = "ldap://openldap",
UsersDn = "dc=example,dc=org",
BindDn = "cn=admin,dc=example,dc=org",
BindCredential = "admin",
SyncRegistrations = true,
});
var assignBarToFoo = new Keycloak.Ldap.HardcodedAttributeMapper("assign_bar_to_foo", new()
{
RealmId = realm.Id,
LdapUserFederationId = ldapUserFederation.Id,
Name = "assign-foo-to-bar",
AttributeName = "foo",
AttributeValue = "bar",
});
});
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.ldap.UserFederation;
import com.pulumi.keycloak.ldap.UserFederationArgs;
import com.pulumi.keycloak.ldap.HardcodedAttributeMapper;
import com.pulumi.keycloak.ldap.HardcodedAttributeMapperArgs;
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 ldapUserFederation = new UserFederation("ldapUserFederation", UserFederationArgs.builder()
.name("openldap")
.realmId(realm.id())
.usernameLdapAttribute("cn")
.rdnLdapAttribute("cn")
.uuidLdapAttribute("entryDN")
.userObjectClasses(
"simpleSecurityObject",
"organizationalRole")
.connectionUrl("ldap://openldap")
.usersDn("dc=example,dc=org")
.bindDn("cn=admin,dc=example,dc=org")
.bindCredential("admin")
.syncRegistrations(true)
.build());
var assignBarToFoo = new HardcodedAttributeMapper("assignBarToFoo", HardcodedAttributeMapperArgs.builder()
.realmId(realm.id())
.ldapUserFederationId(ldapUserFederation.id())
.name("assign-foo-to-bar")
.attributeName("foo")
.attributeValue("bar")
.build());
}
}
resources:
realm:
type: keycloak:Realm
properties:
realm: my-realm
enabled: true
ldapUserFederation:
type: keycloak:ldap:UserFederation
name: ldap_user_federation
properties:
name: openldap
realmId: ${realm.id}
usernameLdapAttribute: cn
rdnLdapAttribute: cn
uuidLdapAttribute: entryDN
userObjectClasses:
- simpleSecurityObject
- organizationalRole
connectionUrl: ldap://openldap
usersDn: dc=example,dc=org
bindDn: cn=admin,dc=example,dc=org
bindCredential: admin
syncRegistrations: true
assignBarToFoo:
type: keycloak:ldap:HardcodedAttributeMapper
name: assign_bar_to_foo
properties:
realmId: ${realm.id}
ldapUserFederationId: ${ldapUserFederation.id}
name: assign-foo-to-bar
attributeName: foo
attributeValue: bar
Create HardcodedAttributeMapper Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new HardcodedAttributeMapper(name: string, args: HardcodedAttributeMapperArgs, opts?: CustomResourceOptions);
@overload
def HardcodedAttributeMapper(resource_name: str,
args: HardcodedAttributeMapperArgs,
opts: Optional[ResourceOptions] = None)
@overload
def HardcodedAttributeMapper(resource_name: str,
opts: Optional[ResourceOptions] = None,
attribute_name: Optional[str] = None,
attribute_value: Optional[str] = None,
ldap_user_federation_id: Optional[str] = None,
realm_id: Optional[str] = None,
name: Optional[str] = None)
func NewHardcodedAttributeMapper(ctx *Context, name string, args HardcodedAttributeMapperArgs, opts ...ResourceOption) (*HardcodedAttributeMapper, error)
public HardcodedAttributeMapper(string name, HardcodedAttributeMapperArgs args, CustomResourceOptions? opts = null)
public HardcodedAttributeMapper(String name, HardcodedAttributeMapperArgs args)
public HardcodedAttributeMapper(String name, HardcodedAttributeMapperArgs args, CustomResourceOptions options)
type: keycloak:ldap:HardcodedAttributeMapper
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 HardcodedAttributeMapperArgs
- 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 HardcodedAttributeMapperArgs
- 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 HardcodedAttributeMapperArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args HardcodedAttributeMapperArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args HardcodedAttributeMapperArgs
- 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 hardcodedAttributeMapperResource = new Keycloak.Ldap.HardcodedAttributeMapper("hardcodedAttributeMapperResource", new()
{
AttributeName = "string",
AttributeValue = "string",
LdapUserFederationId = "string",
RealmId = "string",
Name = "string",
});
example, err := ldap.NewHardcodedAttributeMapper(ctx, "hardcodedAttributeMapperResource", &ldap.HardcodedAttributeMapperArgs{
AttributeName: pulumi.String("string"),
AttributeValue: pulumi.String("string"),
LdapUserFederationId: pulumi.String("string"),
RealmId: pulumi.String("string"),
Name: pulumi.String("string"),
})
var hardcodedAttributeMapperResource = new HardcodedAttributeMapper("hardcodedAttributeMapperResource", HardcodedAttributeMapperArgs.builder()
.attributeName("string")
.attributeValue("string")
.ldapUserFederationId("string")
.realmId("string")
.name("string")
.build());
hardcoded_attribute_mapper_resource = keycloak.ldap.HardcodedAttributeMapper("hardcodedAttributeMapperResource",
attribute_name="string",
attribute_value="string",
ldap_user_federation_id="string",
realm_id="string",
name="string")
const hardcodedAttributeMapperResource = new keycloak.ldap.HardcodedAttributeMapper("hardcodedAttributeMapperResource", {
attributeName: "string",
attributeValue: "string",
ldapUserFederationId: "string",
realmId: "string",
name: "string",
});
type: keycloak:ldap:HardcodedAttributeMapper
properties:
attributeName: string
attributeValue: string
ldapUserFederationId: string
name: string
realmId: string
HardcodedAttributeMapper 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 HardcodedAttributeMapper resource accepts the following input properties:
- Attribute
Name string - The name of the LDAP attribute to set.
- Attribute
Value string - The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
- Ldap
User stringFederation Id - The ID of the LDAP user federation provider to attach this mapper to.
- Realm
Id string - The realm that this LDAP mapper will exist in.
- Name string
- Display name of this mapper when displayed in the console.
- Attribute
Name string - The name of the LDAP attribute to set.
- Attribute
Value string - The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
- Ldap
User stringFederation Id - The ID of the LDAP user federation provider to attach this mapper to.
- Realm
Id string - The realm that this LDAP mapper will exist in.
- Name string
- Display name of this mapper when displayed in the console.
- attribute
Name String - The name of the LDAP attribute to set.
- attribute
Value String - The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
- ldap
User StringFederation Id - The ID of the LDAP user federation provider to attach this mapper to.
- realm
Id String - The realm that this LDAP mapper will exist in.
- name String
- Display name of this mapper when displayed in the console.
- attribute
Name string - The name of the LDAP attribute to set.
- attribute
Value string - The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
- ldap
User stringFederation Id - The ID of the LDAP user federation provider to attach this mapper to.
- realm
Id string - The realm that this LDAP mapper will exist in.
- name string
- Display name of this mapper when displayed in the console.
- attribute_
name str - The name of the LDAP attribute to set.
- attribute_
value str - The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
- ldap_
user_ strfederation_ id - The ID of the LDAP user federation provider to attach this mapper to.
- realm_
id str - The realm that this LDAP mapper will exist in.
- name str
- Display name of this mapper when displayed in the console.
- attribute
Name String - The name of the LDAP attribute to set.
- attribute
Value String - The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
- ldap
User StringFederation Id - The ID of the LDAP user federation provider to attach this mapper to.
- realm
Id String - The realm that this LDAP mapper will exist in.
- name String
- Display name of this mapper when displayed in the console.
Outputs
All input properties are implicitly available as output properties. Additionally, the HardcodedAttributeMapper 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 HardcodedAttributeMapper Resource
Get an existing HardcodedAttributeMapper 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?: HardcodedAttributeMapperState, opts?: CustomResourceOptions): HardcodedAttributeMapper
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
attribute_name: Optional[str] = None,
attribute_value: Optional[str] = None,
ldap_user_federation_id: Optional[str] = None,
name: Optional[str] = None,
realm_id: Optional[str] = None) -> HardcodedAttributeMapper
func GetHardcodedAttributeMapper(ctx *Context, name string, id IDInput, state *HardcodedAttributeMapperState, opts ...ResourceOption) (*HardcodedAttributeMapper, error)
public static HardcodedAttributeMapper Get(string name, Input<string> id, HardcodedAttributeMapperState? state, CustomResourceOptions? opts = null)
public static HardcodedAttributeMapper get(String name, Output<String> id, HardcodedAttributeMapperState 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
Name string - The name of the LDAP attribute to set.
- Attribute
Value string - The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
- Ldap
User stringFederation Id - The ID of the LDAP user federation provider to attach this mapper to.
- Name string
- Display name of this mapper when displayed in the console.
- Realm
Id string - The realm that this LDAP mapper will exist in.
- Attribute
Name string - The name of the LDAP attribute to set.
- Attribute
Value string - The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
- Ldap
User stringFederation Id - The ID of the LDAP user federation provider to attach this mapper to.
- Name string
- Display name of this mapper when displayed in the console.
- Realm
Id string - The realm that this LDAP mapper will exist in.
- attribute
Name String - The name of the LDAP attribute to set.
- attribute
Value String - The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
- ldap
User StringFederation Id - The ID of the LDAP user federation provider to attach this mapper to.
- name String
- Display name of this mapper when displayed in the console.
- realm
Id String - The realm that this LDAP mapper will exist in.
- attribute
Name string - The name of the LDAP attribute to set.
- attribute
Value string - The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
- ldap
User stringFederation Id - The ID of the LDAP user federation provider to attach this mapper to.
- name string
- Display name of this mapper when displayed in the console.
- realm
Id string - The realm that this LDAP mapper will exist in.
- attribute_
name str - The name of the LDAP attribute to set.
- attribute_
value str - The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
- ldap_
user_ strfederation_ id - The ID of the LDAP user federation provider to attach this mapper to.
- name str
- Display name of this mapper when displayed in the console.
- realm_
id str - The realm that this LDAP mapper will exist in.
- attribute
Name String - The name of the LDAP attribute to set.
- attribute
Value String - The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
- ldap
User StringFederation Id - The ID of the LDAP user federation provider to attach this mapper to.
- name String
- Display name of this mapper when displayed in the console.
- realm
Id String - The realm that this LDAP mapper will exist in.
Import
LDAP mappers can be imported using the format {{realm_id}}/{{ldap_user_federation_id}}/{{ldap_mapper_id}}
.
The ID of the LDAP user federation provider and the mapper can be found within the Keycloak GUI, and they are typically GUIDs.
Example:
bash
$ pulumi import keycloak:ldap/hardcodedAttributeMapper:HardcodedAttributeMapper assign_bar_to_foo my-realm/af2a6ca3-e4d7-49c3-b08b-1b3c70b4b860/3d923ece-1a91-4bf7-adaf-3b82f2a12b67
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.