published on Tuesday, Oct 13, 2026 by Pulumi
published on Tuesday, Oct 13, 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.
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().ToIDOutput().ToStringOutput(),
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().ToIDOutput().ToStringOutput(),
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().ToIDOutput().ToStringOutput(),
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().ToIDOutput().ToStringOutput(),
OrganizationId: org.ID().ToIDOutput().ToStringOutput(),
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"
domains {
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)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",
});
example, err := keycloak.NewOrganizationMemberships(ctx, "organizationMembershipsResource", &keycloak.OrganizationMembershipsArgs{
Members: pulumi.StringArray{
pulumi.String("string"),
},
OrganizationId: pulumi.String("string"),
RealmId: pulumi.String("string"),
})
resource "keycloak_organization_memberships" "organizationMembershipsResource" {
lifecycle {
create_before_destroy = true
}
members = ["string"]
organization_id = "string"
realm_id = "string"
}
var organizationMembershipsResource = new OrganizationMemberships("organizationMembershipsResource", OrganizationMembershipsArgs.builder()
.members("string")
.organizationId("string")
.realmId("string")
.build());
organization_memberships_resource = keycloak.OrganizationMemberships("organizationMembershipsResource",
members=["string"],
organization_id="string",
realm_id="string")
const organizationMembershipsResource = new keycloak.OrganizationMemberships("organizationMembershipsResource", {
members: ["string"],
organizationId: "string",
realmId: "string",
});
type: keycloak:OrganizationMemberships
properties:
members:
- string
organizationId: string
realmId: 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.
- Organization
Id string - The ID of the organization to manage memberships for.
- Realm
Id string - The realm the organization belongs to.
- Members []string
- A set of usernames to assign as members of the organization.
- Organization
Id string - The ID of the organization to manage memberships for.
- Realm
Id string - The realm the organization belongs to.
- members list(string)
- A set of usernames to assign as members of the organization.
- organization_
id string - The ID of the organization to manage memberships for.
- realm_
id string - The realm the organization belongs to.
- members List<String>
- A set of usernames to assign as members of the organization.
- organization
Id String - The ID of the organization to manage memberships for.
- realm
Id String - The realm the organization belongs to.
- members string[]
- A set of usernames to assign as members of the organization.
- organization
Id string - The ID of the organization to manage memberships for.
- realm
Id string - The realm the organization belongs to.
- members Sequence[str]
- A set of usernames to assign as members of the organization.
- organization_
id str - The ID of the organization to manage memberships for.
- realm_
id str - The realm the organization belongs to.
- members List<String>
- A set of usernames to assign as members of the organization.
- organization
Id String - The ID of the organization to manage memberships for.
- realm
Id String - The realm the organization belongs to.
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) -> 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: _: type: keycloak:OrganizationMemberships get: id: ${id}import {
to = keycloak_organization_memberships.example
id = "${id}"
}
- 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.
- Members List<string>
- A set of usernames to assign as members of the organization.
- Organization
Id string - The ID of the organization to manage memberships for.
- Realm
Id string - The realm the organization belongs to.
- Members []string
- A set of usernames to assign as members of the organization.
- Organization
Id string - The ID of the organization to manage memberships for.
- Realm
Id string - The realm the organization belongs to.
- members list(string)
- A set of usernames to assign as members of the organization.
- organization_
id string - The ID of the organization to manage memberships for.
- realm_
id string - The realm the organization belongs to.
- members List<String>
- A set of usernames to assign as members of the organization.
- organization
Id String - The ID of the organization to manage memberships for.
- realm
Id String - The realm the organization belongs to.
- members string[]
- A set of usernames to assign as members of the organization.
- organization
Id string - The ID of the organization to manage memberships for.
- realm
Id string - The realm the organization belongs to.
- members Sequence[str]
- A set of usernames to assign as members of the organization.
- organization_
id str - The ID of the organization to manage memberships for.
- realm_
id str - The realm the organization belongs to.
- members List<String>
- A set of usernames to assign as members of the organization.
- organization
Id String - The ID of the organization to manage memberships for.
- realm
Id String - The realm the organization belongs to.
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 Tuesday, Oct 13, 2026 by Pulumi