published on Saturday, Nov 21, 2026 by Pulumi
published on Saturday, Nov 21, 2026 by Pulumi
Allows for managing the members of a Keycloak organization.
Note that this resource attempts to be an authoritative source over organization members. When this resource takes
control over an organization’s members, users that are manually added to the organization will be removed, and users that
are manually removed will be re-added upon the next run of pulumi up.
Managed members are the exception. A membership is managed (MANAGED in Keycloak) when, for example, the user joined
the organization by signing in through an identity provider linked to it (from Keycloak 26.8, a link with managed
membership), or when an administrator changed the membership type to managed (Keycloak 26.8 and later). Keycloak
deletes the user account when a managed membership is removed, so this resource never removes a managed member, listed
in members or not: create, update and destroy leave it in the organization. A managed member is in the resource’s
state only while it is listed in members, so unlisted managed members never cause a diff, and removing a managed
member from members removes it from the state, not from the organization.
This resource paginates its data loading on refresh by 50 items.
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 org = new keycloak.Organization("org", {
realm: realm.id,
name: "my-org",
domains: [{
name: "example.com",
}],
});
const alice = new keycloak.User("alice", {
realmId: realm.id,
username: "alice",
email: "alice@example.com",
});
const bob = new keycloak.User("bob", {
realmId: realm.id,
username: "bob",
email: "bob@example.com",
});
const orgMembers = new keycloak.OrganizationMemberships("org_members", {
realmId: realm.id,
organizationId: org.id,
members: [
alice.username,
bob.username,
],
});
import pulumi
import pulumi_keycloak as keycloak
realm = keycloak.Realm("realm",
realm="my-realm",
enabled=True)
org = keycloak.Organization("org",
realm=realm.id,
name="my-org",
domains=[{
"name": "example.com",
}])
alice = keycloak.User("alice",
realm_id=realm.id,
username="alice",
email="alice@example.com")
bob = keycloak.User("bob",
realm_id=realm.id,
username="bob",
email="bob@example.com")
org_members = keycloak.OrganizationMemberships("org_members",
realm_id=realm.id,
organization_id=org.id,
members=[
alice.username,
bob.username,
])
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"),
Enabled: pulumi.Bool(true),
})
if err != nil {
return err
}
org, err := keycloak.NewOrganization(ctx, "org", &keycloak.OrganizationArgs{
Realm: realm.ID(),
Name: pulumi.String("my-org"),
Domains: keycloak.OrganizationDomainArray{
&keycloak.OrganizationDomainArgs{
Name: pulumi.String("example.com"),
},
},
})
if err != nil {
return err
}
alice, err := keycloak.NewUser(ctx, "alice", &keycloak.UserArgs{
RealmId: realm.ID(),
Username: pulumi.String("alice"),
Email: pulumi.String("alice@example.com"),
})
if err != nil {
return err
}
bob, err := keycloak.NewUser(ctx, "bob", &keycloak.UserArgs{
RealmId: realm.ID(),
Username: pulumi.String("bob"),
Email: pulumi.String("bob@example.com"),
})
if err != nil {
return err
}
_, err = keycloak.NewOrganizationMemberships(ctx, "org_members", &keycloak.OrganizationMembershipsArgs{
RealmId: realm.ID(),
OrganizationId: org.ID(),
Members: pulumi.StringArray{
alice.Username,
bob.Username,
},
})
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 org = new Keycloak.Organization("org", new()
{
Realm = realm.Id,
Name = "my-org",
Domains = new[]
{
new Keycloak.Inputs.OrganizationDomainArgs
{
Name = "example.com",
},
},
});
var alice = new Keycloak.User("alice", new()
{
RealmId = realm.Id,
Username = "alice",
Email = "alice@example.com",
});
var bob = new Keycloak.User("bob", new()
{
RealmId = realm.Id,
Username = "bob",
Email = "bob@example.com",
});
var orgMembers = new Keycloak.OrganizationMemberships("org_members", new()
{
RealmId = realm.Id,
OrganizationId = org.Id,
Members = new[]
{
alice.Username,
bob.Username,
},
});
});
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.Organization;
import com.pulumi.keycloak.OrganizationArgs;
import com.pulumi.keycloak.inputs.OrganizationDomainArgs;
import com.pulumi.keycloak.User;
import com.pulumi.keycloak.UserArgs;
import com.pulumi.keycloak.OrganizationMemberships;
import com.pulumi.keycloak.OrganizationMembershipsArgs;
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")
.enabled(true)
.build());
var org = new Organization("org", OrganizationArgs.builder()
.realm(realm.id())
.name("my-org")
.domains(OrganizationDomainArgs.builder()
.name("example.com")
.build())
.build());
var alice = new User("alice", UserArgs.builder()
.realmId(realm.id())
.username("alice")
.email("alice@example.com")
.build());
var bob = new User("bob", UserArgs.builder()
.realmId(realm.id())
.username("bob")
.email("bob@example.com")
.build());
var orgMembers = new OrganizationMemberships("orgMembers", OrganizationMembershipsArgs.builder()
.realmId(realm.id())
.organizationId(org.id())
.members(
alice.username(),
bob.username())
.build());
}
}
resources:
realm:
type: keycloak:Realm
properties:
realm: my-realm
enabled: true
org:
type: keycloak:Organization
properties:
realm: ${realm.id}
name: my-org
domains:
- name: example.com
alice:
type: keycloak:User
properties:
realmId: ${realm.id}
username: alice
email: alice@example.com
bob:
type: keycloak:User
properties:
realmId: ${realm.id}
username: bob
email: bob@example.com
orgMembers:
type: keycloak:OrganizationMemberships
name: org_members
properties:
realmId: ${realm.id}
organizationId: ${org.id}
members:
- ${alice.username}
- ${bob.username}
terraform {
required_providers {
keycloak = {
source = "pulumi/keycloak"
}
}
}
resource "keycloak_realm" "realm" {
lifecycle {
create_before_destroy = true
}
realm = "my-realm"
enabled = true
}
resource "keycloak_organization" "org" {
lifecycle {
create_before_destroy = true
}
realm = keycloak_realm.realm.id
name = "my-org"
domain {
name = "example.com"
}
}
resource "keycloak_user" "alice" {
lifecycle {
create_before_destroy = true
}
realm_id = keycloak_realm.realm.id
username = "alice"
email = "alice@example.com"
}
resource "keycloak_user" "bob" {
lifecycle {
create_before_destroy = true
}
realm_id = keycloak_realm.realm.id
username = "bob"
email = "bob@example.com"
}
resource "keycloak_organization_memberships" "org_members" {
lifecycle {
create_before_destroy = true
}
realm_id = keycloak_realm.realm.id
organization_id = keycloak_organization.org.id
members = [keycloak_user.alice.username, keycloak_user.bob.username]
}
Create OrganizationMemberships Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new OrganizationMemberships(name: string, args: OrganizationMembershipsArgs, opts?: CustomResourceOptions);@overload
def OrganizationMemberships(resource_name: str,
args: OrganizationMembershipsArgs,
opts: Optional[ResourceOptions] = None)
@overload
def OrganizationMemberships(resource_name: str,
opts: Optional[ResourceOptions] = None,
members: Optional[Sequence[str]] = None,
organization_id: Optional[str] = None,
realm_id: Optional[str] = None,
realm_internal_id: Optional[str] = None)func NewOrganizationMemberships(ctx *Context, name string, args OrganizationMembershipsArgs, opts ...ResourceOption) (*OrganizationMemberships, error)public OrganizationMemberships(string name, OrganizationMembershipsArgs args, CustomResourceOptions? opts = null)
public OrganizationMemberships(String name, OrganizationMembershipsArgs args)
public OrganizationMemberships(String name, OrganizationMembershipsArgs args, CustomResourceOptions options)
type: keycloak:OrganizationMemberships
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
resource "keycloak_organization_memberships" "name" {
# resource properties
}Parameters
- name string
- The unique name of the resource.
- args OrganizationMembershipsArgs
- 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 OrganizationMembershipsArgs
- 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 OrganizationMembershipsArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args OrganizationMembershipsArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args OrganizationMembershipsArgs
- 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 organizationMembershipsResource = new Keycloak.OrganizationMemberships("organizationMembershipsResource", new()
{
Members = new[]
{
"string",
},
OrganizationId = "string",
RealmId = "string",
RealmInternalId = "string",
});
example, err := keycloak.NewOrganizationMemberships(ctx, "organizationMembershipsResource", &keycloak.OrganizationMembershipsArgs{
Members: pulumi.StringArray{
pulumi.String("string"),
},
OrganizationId: pulumi.String("string"),
RealmId: pulumi.String("string"),
RealmInternalId: pulumi.String("string"),
})
resource "keycloak_organization_memberships" "organizationMembershipsResource" {
lifecycle {
create_before_destroy = true
}
members = ["string"]
organization_id = "string"
realm_id = "string"
realm_internal_id = "string"
}
var organizationMembershipsResource = new OrganizationMemberships("organizationMembershipsResource", OrganizationMembershipsArgs.builder()
.members("string")
.organizationId("string")
.realmId("string")
.realmInternalId("string")
.build());
organization_memberships_resource = keycloak.OrganizationMemberships("organizationMembershipsResource",
members=["string"],
organization_id="string",
realm_id="string",
realm_internal_id="string")
const organizationMembershipsResource = new keycloak.OrganizationMemberships("organizationMembershipsResource", {
members: ["string"],
organizationId: "string",
realmId: "string",
realmInternalId: "string",
});
type: keycloak:OrganizationMemberships
properties:
members:
- string
organizationId: string
realmId: string
realmInternalId: string
OrganizationMemberships 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 OrganizationMemberships resource accepts the following input properties:
- Members List<string>
- A set of usernames to assign as members of the organization. Managed members may be listed, but are never removed.
- Organization
Id string - The ID of the organization to manage memberships for.
- Realm
Id string - The realm the organization belongs to.
- 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.
- Members []string
- A set of usernames to assign as members of the organization. Managed members may be listed, but are never removed.
- Organization
Id string - The ID of the organization to manage memberships for.
- Realm
Id string - The realm the organization belongs to.
- 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.
- members list(string)
- A set of usernames to assign as members of the organization. Managed members may be listed, but are never removed.
- organization_
id string - The ID of the organization to manage memberships for.
- realm_
id string - The realm the organization belongs to.
- 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.
- members List<String>
- A set of usernames to assign as members of the organization. Managed members may be listed, but are never removed.
- organization
Id String - The ID of the organization to manage memberships for.
- realm
Id String - The realm the organization belongs to.
- 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.
- members string[]
- A set of usernames to assign as members of the organization. Managed members may be listed, but are never removed.
- organization
Id string - The ID of the organization to manage memberships for.
- realm
Id string - The realm the organization belongs to.
- 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.
- members Sequence[str]
- A set of usernames to assign as members of the organization. Managed members may be listed, but are never removed.
- organization_
id str - The ID of the organization to manage memberships for.
- realm_
id str - The realm the organization belongs to.
- 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.
- members List<String>
- A set of usernames to assign as members of the organization. Managed members may be listed, but are never removed.
- organization
Id String - The ID of the organization to manage memberships for.
- realm
Id String - The realm the organization belongs to.
- 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 OrganizationMemberships 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 OrganizationMemberships Resource
Get an existing OrganizationMemberships 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?: OrganizationMembershipsState, opts?: CustomResourceOptions): OrganizationMemberships@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
members: Optional[Sequence[str]] = None,
organization_id: Optional[str] = None,
realm_id: Optional[str] = None,
realm_internal_id: Optional[str] = None) -> OrganizationMembershipsfunc GetOrganizationMemberships(ctx *Context, name string, id IDInput, state *OrganizationMembershipsState, opts ...ResourceOption) (*OrganizationMemberships, error)public static OrganizationMemberships Get(string name, Input<string> id, OrganizationMembershipsState? state, CustomResourceOptions? opts = null)public static OrganizationMemberships get(String name, Output<String> id, OrganizationMembershipsState state, CustomResourceOptions options)resources: existingOrganizationMemberships: type: keycloak:OrganizationMemberships get: id: ${id}import {
to = keycloak_organization_memberships.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 OrganizationMembershipsState
- 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 OrganizationMembershipsState
- 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 OrganizationMembershipsState
- 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 OrganizationMembershipsState
- 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.
- Members List<string>
- A set of usernames to assign as members of the organization. Managed members may be listed, but are never removed.
- Organization
Id string - The ID of the organization to manage memberships for.
- Realm
Id string - The realm the organization belongs to.
- 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.
- Members []string
- A set of usernames to assign as members of the organization. Managed members may be listed, but are never removed.
- Organization
Id string - The ID of the organization to manage memberships for.
- Realm
Id string - The realm the organization belongs to.
- 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.
- members list(string)
- A set of usernames to assign as members of the organization. Managed members may be listed, but are never removed.
- organization_
id string - The ID of the organization to manage memberships for.
- realm_
id string - The realm the organization belongs to.
- 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.
- members List<String>
- A set of usernames to assign as members of the organization. Managed members may be listed, but are never removed.
- organization
Id String - The ID of the organization to manage memberships for.
- realm
Id String - The realm the organization belongs to.
- 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.
- members string[]
- A set of usernames to assign as members of the organization. Managed members may be listed, but are never removed.
- organization
Id string - The ID of the organization to manage memberships for.
- realm
Id string - The realm the organization belongs to.
- 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.
- members Sequence[str]
- A set of usernames to assign as members of the organization. Managed members may be listed, but are never removed.
- organization_
id str - The ID of the organization to manage memberships for.
- realm_
id str - The realm the organization belongs to.
- 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.
- members List<String>
- A set of usernames to assign as members of the organization. Managed members may be listed, but are never removed.
- organization
Id String - The ID of the organization to manage memberships for.
- realm
Id String - The realm the organization belongs to.
- 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
This resource does not support import. Instead of importing, feel free to create this resource as if it did not already exist on the server.
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