User

# keycloak..User

Allows for creating and managing Users within Keycloak.

This resource was created primarily to enable the acceptance tests for the keycloak..Group resource. Creating users within Keycloak is not recommended. Instead, users should be federated from external sources by configuring user federation providers or identity providers.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";

const realm = new keycloak.Realm("realm", {
    enabled: true,
    realm: "my-realm",
});
const user = new keycloak.User("user", {
    email: "bob@domain.com",
    enabled: true,
    firstName: "Bob",
    lastName: "Bobson",
    realmId: realm.id,
    username: "bob",
});
const userWithInitialPassword = new keycloak.User("user_with_initial_password", {
    email: "alice@domain.com",
    enabled: true,
    firstName: "Alice",
    initialPassword: {
        temporary: true,
        value: "some password",
    },
    lastName: "Aliceberg",
    realmId: realm.id,
    username: "alice",
});
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    enabled=True,
    realm="my-realm")
user = keycloak.User("user",
    email="bob@domain.com",
    enabled=True,
    first_name="Bob",
    last_name="Bobson",
    realm_id=realm.id,
    username="bob")
user_with_initial_password = keycloak.User("userWithInitialPassword",
    email="alice@domain.com",
    enabled=True,
    first_name="Alice",
    initial_password={
        "temporary": True,
        "value": "some password",
    },
    last_name="Aliceberg",
    realm_id=realm.id,
    username="alice")
using Pulumi;
using Keycloak = Pulumi.Keycloak;

class MyStack : Stack
{
    public MyStack()
    {
        var realm = new Keycloak.Realm("realm", new Keycloak.RealmArgs
        {
            Enabled = true,
            Realm = "my-realm",
        });
        var user = new Keycloak.User("user", new Keycloak.UserArgs
        {
            Email = "bob@domain.com",
            Enabled = true,
            FirstName = "Bob",
            LastName = "Bobson",
            RealmId = realm.Id,
            Username = "bob",
        });
        var userWithInitialPassword = new Keycloak.User("userWithInitialPassword", new Keycloak.UserArgs
        {
            Email = "alice@domain.com",
            Enabled = true,
            FirstName = "Alice",
            InitialPassword = new Keycloak.Inputs.UserInitialPasswordArgs
            {
                Temporary = true,
                Value = "some password",
            },
            LastName = "Aliceberg",
            RealmId = realm.Id,
            Username = "alice",
        });
    }

}

Argument Reference

The following arguments are supported:

  • realm_id - (Required) The realm this user belongs to.
  • username - (Required) The unique username of this user.
  • initial_password (Optional) When given, the user’s initial password will be set. This attribute is only respected during initial user creation.
    • value (Required) The initial password.
    • temporary (Optional) If set to true, the initial password is set up for renewal on first use. Default to false.
  • enabled - (Optional) When false, this user cannot log in. Defaults to true.
  • email - (Optional) The user’s email.
  • first_name - (Optional) The user’s first name.
  • last_name - (Optional) The user’s last name.

Create a User Resource

new User(name: string, args: UserArgs, opts?: CustomResourceOptions);
def User(resource_name, opts=None, attributes=None, email=None, email_verified=None, enabled=None, federated_identities=None, first_name=None, initial_password=None, last_name=None, realm_id=None, username=None, __props__=None);
func NewUser(ctx *Context, name string, args UserArgs, opts ...ResourceOption) (*User, error)
public User(string name, UserArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args UserArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args UserArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args UserArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

User Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The User resource accepts the following input properties:

RealmId string
Username string
Attributes Dictionary<string, object>
Email string
EmailVerified bool
Enabled bool
FederatedIdentities List<UserFederatedIdentityArgs>
FirstName string
InitialPassword UserInitialPasswordArgs
LastName string
RealmId string
Username string
Attributes map[string]interface{}
Email string
EmailVerified bool
Enabled bool
FederatedIdentities []UserFederatedIdentity
FirstName string
InitialPassword UserInitialPassword
LastName string
realmId string
username string
attributes {[key: string]: any}
email string
emailVerified boolean
enabled boolean
federatedIdentities UserFederatedIdentity[]
firstName string
initialPassword UserInitialPassword
lastName string
realm_id str
username str
attributes Dict[str, Any]
email str
email_verified bool
enabled bool
federated_identities List[UserFederatedIdentity]
first_name str
initial_password Dict[UserInitialPassword]
last_name str

Outputs

All input properties are implicitly available as output properties. Additionally, the User 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 str
The provider-assigned unique ID for this managed resource.

Look up an Existing User Resource

Get an existing User 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?: UserState, opts?: CustomResourceOptions): User
static get(resource_name, id, opts=None, attributes=None, email=None, email_verified=None, enabled=None, federated_identities=None, first_name=None, initial_password=None, last_name=None, realm_id=None, username=None, __props__=None);
func GetUser(ctx *Context, name string, id IDInput, state *UserState, opts ...ResourceOption) (*User, error)
public static User Get(string name, Input<string> id, UserState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

Attributes Dictionary<string, object>
Email string
EmailVerified bool
Enabled bool
FederatedIdentities List<UserFederatedIdentityArgs>
FirstName string
InitialPassword UserInitialPasswordArgs
LastName string
RealmId string
Username string
Attributes map[string]interface{}
Email string
EmailVerified bool
Enabled bool
FederatedIdentities []UserFederatedIdentity
FirstName string
InitialPassword UserInitialPassword
LastName string
RealmId string
Username string
attributes {[key: string]: any}
email string
emailVerified boolean
enabled boolean
federatedIdentities UserFederatedIdentity[]
firstName string
initialPassword UserInitialPassword
lastName string
realmId string
username string
attributes Dict[str, Any]
email str
email_verified bool
enabled bool
federated_identities List[UserFederatedIdentity]
first_name str
initial_password Dict[UserInitialPassword]
last_name str
realm_id str
username str

Supporting Types

UserFederatedIdentity

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

IdentityProvider string
UserId string
UserName string
IdentityProvider string
UserId string
UserName string
identityProvider string
userId string
userName string
identityProvider str
userId str
userName str

UserInitialPassword

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Value string
Temporary bool
Value string
Temporary bool
value string
temporary boolean
value str
temporary bool

Package Details

Repository
https://github.com/pulumi/pulumi-keycloak
License
Apache-2.0
Notes
This Pulumi package is based on the keycloak Terraform Provider.