published on Saturday, Nov 21, 2026 by Pulumi
published on Saturday, Nov 21, 2026 by Pulumi
Allows for creating and managing Realm keystores of any key provider within Keycloak, including key providers from custom extensions (for example a key provider that signs tokens with a key held in an HSM).
A realm keystore manages keys that are used by Keycloak to perform cryptographic signatures and encryption.
For built-in key providers that have their own resource, such as keycloak.RealmKeystoreRsaGenerated, prefer that
resource, as it validates the config at plan time and documents the available arguments.
Example Usage
Key provider from a custom extension
import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";
const realm = new keycloak.Realm("realm", {realm: "my-realm"});
const hsm = new keycloak.RealmKeystoreCustom("hsm", {
name: "hsm-token-signing",
realmId: realm.id,
providerId: "my-hsm-key-provider",
config: {
priority: "200",
endpoint: "hsm.example.com:50051",
keyId: "token-signing-es256",
},
});
import pulumi
import pulumi_keycloak as keycloak
realm = keycloak.Realm("realm", realm="my-realm")
hsm = keycloak.RealmKeystoreCustom("hsm",
name="hsm-token-signing",
realm_id=realm.id,
provider_id="my-hsm-key-provider",
config={
"priority": "200",
"endpoint": "hsm.example.com:50051",
"keyId": "token-signing-es256",
})
package main
import (
"github.com/pulumi/pulumi-keycloak/sdk/v6/go/keycloak"
"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"),
})
if err != nil {
return err
}
_, err = keycloak.NewRealmKeystoreCustom(ctx, "hsm", &keycloak.RealmKeystoreCustomArgs{
Name: pulumi.String("hsm-token-signing"),
RealmId: realm.ID(),
ProviderId: pulumi.String("my-hsm-key-provider"),
Config: pulumi.StringMap{
"priority": pulumi.String("200"),
"endpoint": pulumi.String("hsm.example.com:50051"),
"keyId": pulumi.String("token-signing-es256"),
},
})
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",
});
var hsm = new Keycloak.RealmKeystoreCustom("hsm", new()
{
Name = "hsm-token-signing",
RealmId = realm.Id,
ProviderId = "my-hsm-key-provider",
Config =
{
{ "priority", "200" },
{ "endpoint", "hsm.example.com:50051" },
{ "keyId", "token-signing-es256" },
},
});
});
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.RealmKeystoreCustom;
import com.pulumi.keycloak.RealmKeystoreCustomArgs;
import java.util.ArrayList;
import java.util.Arrays;
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")
.build());
var hsm = new RealmKeystoreCustom("hsm", RealmKeystoreCustomArgs.builder()
.name("hsm-token-signing")
.realmId(realm.id())
.providerId("my-hsm-key-provider")
.config(Map.ofEntries(
Map.entry("priority", "200"),
Map.entry("endpoint", "hsm.example.com:50051"),
Map.entry("keyId", "token-signing-es256")
))
.build());
}
}
resources:
realm:
type: keycloak:Realm
properties:
realm: my-realm
hsm:
type: keycloak:RealmKeystoreCustom
properties:
name: hsm-token-signing
realmId: ${realm.id}
providerId: my-hsm-key-provider
config:
priority: '200'
endpoint: hsm.example.com:50051
keyId: token-signing-es256
terraform {
required_providers {
keycloak = {
source = "pulumi/keycloak"
}
}
}
resource "keycloak_realm" "realm" {
lifecycle {
create_before_destroy = true
}
realm = "my-realm"
}
resource "keycloak_realm_keystore_custom" "hsm" {
lifecycle {
create_before_destroy = true
}
name = "hsm-token-signing"
realm_id = keycloak_realm.realm.id
provider_id = "my-hsm-key-provider"
config = {
"priority" = "200"
"endpoint" = "hsm.example.com:50051"
"keyId" = "token-signing-es256"
}
}
Built-in key provider without its own resource
import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";
const eddsa = new keycloak.RealmKeystoreCustom("eddsa", {
name: "eddsa-generated",
realmId: realm.id,
providerId: "eddsa-generated",
config: {
priority: "100",
enabled: "true",
active: "true",
eddsaEllipticCurveKey: "Ed25519",
},
});
import pulumi
import pulumi_keycloak as keycloak
eddsa = keycloak.RealmKeystoreCustom("eddsa",
name="eddsa-generated",
realm_id=realm["id"],
provider_id="eddsa-generated",
config={
"priority": "100",
"enabled": "true",
"active": "true",
"eddsaEllipticCurveKey": "Ed25519",
})
package main
import (
"github.com/pulumi/pulumi-keycloak/sdk/v6/go/keycloak"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := keycloak.NewRealmKeystoreCustom(ctx, "eddsa", &keycloak.RealmKeystoreCustomArgs{
Name: pulumi.String("eddsa-generated"),
RealmId: pulumi.Any(realm.Id),
ProviderId: pulumi.String("eddsa-generated"),
Config: pulumi.StringMap{
"priority": pulumi.String("100"),
"enabled": pulumi.String("true"),
"active": pulumi.String("true"),
"eddsaEllipticCurveKey": pulumi.String("Ed25519"),
},
})
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 eddsa = new Keycloak.RealmKeystoreCustom("eddsa", new()
{
Name = "eddsa-generated",
RealmId = realm.Id,
ProviderId = "eddsa-generated",
Config =
{
{ "priority", "100" },
{ "enabled", "true" },
{ "active", "true" },
{ "eddsaEllipticCurveKey", "Ed25519" },
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.keycloak.RealmKeystoreCustom;
import com.pulumi.keycloak.RealmKeystoreCustomArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 eddsa = new RealmKeystoreCustom("eddsa", RealmKeystoreCustomArgs.builder()
.name("eddsa-generated")
.realmId(realm.get("id"))
.providerId("eddsa-generated")
.config(Map.ofEntries(
Map.entry("priority", "100"),
Map.entry("enabled", "true"),
Map.entry("active", "true"),
Map.entry("eddsaEllipticCurveKey", "Ed25519")
))
.build());
}
}
resources:
eddsa:
type: keycloak:RealmKeystoreCustom
properties:
name: eddsa-generated
realmId: ${realm.id}
providerId: eddsa-generated
config:
priority: '100'
enabled: 'true'
active: 'true'
eddsaEllipticCurveKey: Ed25519
terraform {
required_providers {
keycloak = {
source = "pulumi/keycloak"
}
}
}
resource "keycloak_realm_keystore_custom" "eddsa" {
lifecycle {
create_before_destroy = true
}
name = "eddsa-generated"
realm_id = realm.id
provider_id = "eddsa-generated"
config = {
"priority" = "100"
"enabled" = "true"
"active" = "true"
"eddsaEllipticCurveKey" = "Ed25519"
}
}
Create RealmKeystoreCustom Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new RealmKeystoreCustom(name: string, args: RealmKeystoreCustomArgs, opts?: CustomResourceOptions);@overload
def RealmKeystoreCustom(resource_name: str,
args: RealmKeystoreCustomArgs,
opts: Optional[ResourceOptions] = None)
@overload
def RealmKeystoreCustom(resource_name: str,
opts: Optional[ResourceOptions] = None,
provider_id: Optional[str] = None,
config: Optional[Mapping[str, str]] = None,
name: Optional[str] = None,
realm_id: Optional[str] = None,
realm_internal_id: Optional[str] = None)func NewRealmKeystoreCustom(ctx *Context, name string, args RealmKeystoreCustomArgs, opts ...ResourceOption) (*RealmKeystoreCustom, error)public RealmKeystoreCustom(string name, RealmKeystoreCustomArgs args, CustomResourceOptions? opts = null)
public RealmKeystoreCustom(String name, RealmKeystoreCustomArgs args)
public RealmKeystoreCustom(String name, RealmKeystoreCustomArgs args, CustomResourceOptions options)
type: keycloak:RealmKeystoreCustom
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
resource "keycloak_realm_keystore_custom" "name" {
# resource properties
}Parameters
- name string
- The unique name of the resource.
- args RealmKeystoreCustomArgs
- 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 RealmKeystoreCustomArgs
- 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 RealmKeystoreCustomArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RealmKeystoreCustomArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args RealmKeystoreCustomArgs
- 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 realmKeystoreCustomResource = new Keycloak.RealmKeystoreCustom("realmKeystoreCustomResource", new()
{
ProviderId = "string",
Config =
{
{ "string", "string" },
},
Name = "string",
RealmId = "string",
RealmInternalId = "string",
});
example, err := keycloak.NewRealmKeystoreCustom(ctx, "realmKeystoreCustomResource", &keycloak.RealmKeystoreCustomArgs{
ProviderId: pulumi.String("string"),
Config: pulumi.StringMap{
"string": pulumi.String("string"),
},
Name: pulumi.String("string"),
RealmId: pulumi.String("string"),
RealmInternalId: pulumi.String("string"),
})
resource "keycloak_realm_keystore_custom" "realmKeystoreCustomResource" {
lifecycle {
create_before_destroy = true
}
provider_id = "string"
config = {
"string" = "string"
}
name = "string"
realm_id = "string"
realm_internal_id = "string"
}
var realmKeystoreCustomResource = new RealmKeystoreCustom("realmKeystoreCustomResource", RealmKeystoreCustomArgs.builder()
.providerId("string")
.config(Map.of("string", "string"))
.name("string")
.realmId("string")
.realmInternalId("string")
.build());
realm_keystore_custom_resource = keycloak.RealmKeystoreCustom("realmKeystoreCustomResource",
provider_id="string",
config={
"string": "string",
},
name="string",
realm_id="string",
realm_internal_id="string")
const realmKeystoreCustomResource = new keycloak.RealmKeystoreCustom("realmKeystoreCustomResource", {
providerId: "string",
config: {
string: "string",
},
name: "string",
realmId: "string",
realmInternalId: "string",
});
type: keycloak:RealmKeystoreCustom
properties:
config:
string: string
name: string
providerId: string
realmId: string
realmInternalId: string
RealmKeystoreCustom 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 RealmKeystoreCustom resource accepts the following input properties:
- Provider
Id string - The id of the key provider, as returned by the
getIdimplementation of itsKeyProviderFactory. Changing this forces a new resource. - Config Dictionary<string, string>
- A map of config keys and values of the key provider. Common keys are
priority,enabledandactive, the other keys depend on the key provider. - Name string
- Display name of provider when linked in admin console.
- Realm
Id string - The realm this keystore exists in.
- Realm
Internal stringId - The internal id of the realm, as an alternative to realm_id. Unlike the realm name, it does not change when the realm is renamed.
- Provider
Id string - The id of the key provider, as returned by the
getIdimplementation of itsKeyProviderFactory. Changing this forces a new resource. - Config map[string]string
- A map of config keys and values of the key provider. Common keys are
priority,enabledandactive, the other keys depend on the key provider. - Name string
- Display name of provider when linked in admin console.
- Realm
Id string - The realm this keystore exists in.
- Realm
Internal stringId - The internal id of the realm, as an alternative to realm_id. Unlike the realm name, it does not change when the realm is renamed.
- provider_
id string - The id of the key provider, as returned by the
getIdimplementation of itsKeyProviderFactory. Changing this forces a new resource. - config map(string)
- A map of config keys and values of the key provider. Common keys are
priority,enabledandactive, the other keys depend on the key provider. - name string
- Display name of provider when linked in admin console.
- realm_
id string - The realm this keystore exists in.
- realm_
internal_ stringid - The internal id of the realm, as an alternative to realm_id. Unlike the realm name, it does not change when the realm is renamed.
- provider
Id String - The id of the key provider, as returned by the
getIdimplementation of itsKeyProviderFactory. Changing this forces a new resource. - config Map<String,String>
- A map of config keys and values of the key provider. Common keys are
priority,enabledandactive, the other keys depend on the key provider. - name String
- Display name of provider when linked in admin console.
- realm
Id String - The realm this keystore exists in.
- realm
Internal StringId - The internal id of the realm, as an alternative to realm_id. Unlike the realm name, it does not change when the realm is renamed.
- provider
Id string - The id of the key provider, as returned by the
getIdimplementation of itsKeyProviderFactory. Changing this forces a new resource. - config {[key: string]: string}
- A map of config keys and values of the key provider. Common keys are
priority,enabledandactive, the other keys depend on the key provider. - name string
- Display name of provider when linked in admin console.
- realm
Id string - The realm this keystore exists in.
- realm
Internal stringId - The internal id of the realm, as an alternative to realm_id. Unlike the realm name, it does not change when the realm is renamed.
- provider_
id str - The id of the key provider, as returned by the
getIdimplementation of itsKeyProviderFactory. Changing this forces a new resource. - config Mapping[str, str]
- A map of config keys and values of the key provider. Common keys are
priority,enabledandactive, the other keys depend on the key provider. - name str
- Display name of provider when linked in admin console.
- realm_
id str - The realm this keystore exists in.
- realm_
internal_ strid - The internal id of the realm, as an alternative to realm_id. Unlike the realm name, it does not change when the realm is renamed.
- provider
Id String - The id of the key provider, as returned by the
getIdimplementation of itsKeyProviderFactory. Changing this forces a new resource. - config Map<String>
- A map of config keys and values of the key provider. Common keys are
priority,enabledandactive, the other keys depend on the key provider. - name String
- Display name of provider when linked in admin console.
- realm
Id String - The realm this keystore exists in.
- realm
Internal StringId - The internal id of the realm, as an alternative to realm_id. Unlike the realm name, it does not change when the realm is renamed.
Outputs
All input properties are implicitly available as output properties. Additionally, the RealmKeystoreCustom 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 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 RealmKeystoreCustom Resource
Get an existing RealmKeystoreCustom 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?: RealmKeystoreCustomState, opts?: CustomResourceOptions): RealmKeystoreCustom@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
config: Optional[Mapping[str, str]] = None,
name: Optional[str] = None,
provider_id: Optional[str] = None,
realm_id: Optional[str] = None,
realm_internal_id: Optional[str] = None) -> RealmKeystoreCustomfunc GetRealmKeystoreCustom(ctx *Context, name string, id IDInput, state *RealmKeystoreCustomState, opts ...ResourceOption) (*RealmKeystoreCustom, error)public static RealmKeystoreCustom Get(string name, Input<string> id, RealmKeystoreCustomState? state, CustomResourceOptions? opts = null)public static RealmKeystoreCustom get(String name, Output<String> id, RealmKeystoreCustomState state, CustomResourceOptions options)resources: existingRealmKeystoreCustom: type: keycloak:RealmKeystoreCustom get: id: ${id}import {
to = keycloak_realm_keystore_custom.example
id = "${id}"
}
- name string
- The unique name of the resulting resource.
- id Input<ID>
- The unique provider ID of the resource to look up.
- state RealmKeystoreCustomState
- Known property values the provider needs, along with the ID, to find the resource. Usually not required.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resulting resource.
- id str
- The unique provider ID of the resource to look up.
- 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 resulting resource.
- id IDInput
- The unique provider ID of the resource to look up.
- state RealmKeystoreCustomState
- Known property values the provider needs, along with the ID, to find the resource. Usually not required.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resulting resource.
- id Input<string>
- The unique provider ID of the resource to look up.
- state RealmKeystoreCustomState
- Known property values the provider needs, along with the ID, to find the resource. Usually not required.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resulting resource.
- id Output<String>
- The unique provider ID of the resource to look up.
- state RealmKeystoreCustomState
- Known property values the provider needs, along with the ID, to find the resource. Usually not required.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
- Config Dictionary<string, string>
- A map of config keys and values of the key provider. Common keys are
priority,enabledandactive, the other keys depend on the key provider. - Name string
- Display name of provider when linked in admin console.
- Provider
Id string - The id of the key provider, as returned by the
getIdimplementation of itsKeyProviderFactory. Changing this forces a new resource. - Realm
Id string - The realm this keystore exists in.
- Realm
Internal stringId - The internal id of the realm, as an alternative to realm_id. Unlike the realm name, it does not change when the realm is renamed.
- Config map[string]string
- A map of config keys and values of the key provider. Common keys are
priority,enabledandactive, the other keys depend on the key provider. - Name string
- Display name of provider when linked in admin console.
- Provider
Id string - The id of the key provider, as returned by the
getIdimplementation of itsKeyProviderFactory. Changing this forces a new resource. - Realm
Id string - The realm this keystore exists in.
- Realm
Internal stringId - The internal id of the realm, as an alternative to realm_id. Unlike the realm name, it does not change when the realm is renamed.
- config map(string)
- A map of config keys and values of the key provider. Common keys are
priority,enabledandactive, the other keys depend on the key provider. - name string
- Display name of provider when linked in admin console.
- provider_
id string - The id of the key provider, as returned by the
getIdimplementation of itsKeyProviderFactory. Changing this forces a new resource. - realm_
id string - The realm this keystore exists in.
- realm_
internal_ stringid - The internal id of the realm, as an alternative to realm_id. Unlike the realm name, it does not change when the realm is renamed.
- config Map<String,String>
- A map of config keys and values of the key provider. Common keys are
priority,enabledandactive, the other keys depend on the key provider. - name String
- Display name of provider when linked in admin console.
- provider
Id String - The id of the key provider, as returned by the
getIdimplementation of itsKeyProviderFactory. Changing this forces a new resource. - realm
Id String - The realm this keystore exists in.
- realm
Internal StringId - The internal id of the realm, as an alternative to realm_id. Unlike the realm name, it does not change when the realm is renamed.
- config {[key: string]: string}
- A map of config keys and values of the key provider. Common keys are
priority,enabledandactive, the other keys depend on the key provider. - name string
- Display name of provider when linked in admin console.
- provider
Id string - The id of the key provider, as returned by the
getIdimplementation of itsKeyProviderFactory. Changing this forces a new resource. - realm
Id string - The realm this keystore exists in.
- realm
Internal stringId - The internal id of the realm, as an alternative to realm_id. Unlike the realm name, it does not change when the realm is renamed.
- config Mapping[str, str]
- A map of config keys and values of the key provider. Common keys are
priority,enabledandactive, the other keys depend on the key provider. - name str
- Display name of provider when linked in admin console.
- provider_
id str - The id of the key provider, as returned by the
getIdimplementation of itsKeyProviderFactory. Changing this forces a new resource. - realm_
id str - The realm this keystore exists in.
- realm_
internal_ strid - The internal id of the realm, as an alternative to realm_id. Unlike the realm name, it does not change when the realm is renamed.
- config Map<String>
- A map of config keys and values of the key provider. Common keys are
priority,enabledandactive, the other keys depend on the key provider. - name String
- Display name of provider when linked in admin console.
- provider
Id String - The id of the key provider, as returned by the
getIdimplementation of itsKeyProviderFactory. Changing this forces a new resource. - realm
Id String - The realm this keystore exists in.
- realm
Internal StringId - The internal id of the realm, as an alternative to realm_id. Unlike the realm name, it does not change when the realm is renamed.
Import
Realm keystores can be imported using one of the following formats:
{{realmId}}/{{keystoreId}}, you can find the keystore id in the web UI.{{realmId}}/{{name}}/{{providerId}}, which lets you import keystores with static values in animportblock. The import fails if more than one keystore of the realm has this name and provider id.
The import fails if the id belongs to a component that is not a key provider, for example a user federation.
The import takes all config keys that Keycloak returns, with secret values masked as **********. Keys that are
missing from the config of the resource are removed on the next apply, and secret values are set again.
Example:
$ pulumi import keycloak:index/realmKeystoreCustom:RealmKeystoreCustom hsm my-realm/618cfba7-49aa-4c09-9a19-2f699b576f0b
$ pulumi import keycloak:index/realmKeystoreCustom:RealmKeystoreCustom hsm my-realm/hsm-token-signing/my-hsm-key-provider
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
keycloakTerraform Provider.
published on Saturday, Nov 21, 2026 by Pulumi