Keycloak v5.3.2 published on Friday, May 10, 2024 by Pulumi
keycloak.getUser
Explore with Pulumi AI
This data source can be used to fetch properties of a user within Keycloak.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";
const masterRealm = keycloak.getRealm({
    realm: "master",
});
// use the keycloak_user data source to grab the admin user's ID
const defaultAdminUser = masterRealm.then(masterRealm => keycloak.getUser({
    realmId: masterRealm.id,
    username: "keycloak",
}));
export const keycloakUserId = defaultAdminUser.then(defaultAdminUser => defaultAdminUser.id);
import pulumi
import pulumi_keycloak as keycloak
master_realm = keycloak.get_realm(realm="master")
# use the keycloak_user data source to grab the admin user's ID
default_admin_user = keycloak.get_user(realm_id=master_realm.id,
    username="keycloak")
pulumi.export("keycloakUserId", default_admin_user.id)
package main
import (
	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		masterRealm, err := keycloak.LookupRealm(ctx, &keycloak.LookupRealmArgs{
			Realm: "master",
		}, nil)
		if err != nil {
			return err
		}
		// use the keycloak_user data source to grab the admin user's ID
		defaultAdminUser, err := keycloak.LookupUser(ctx, &keycloak.LookupUserArgs{
			RealmId:  masterRealm.Id,
			Username: "keycloak",
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("keycloakUserId", defaultAdminUser.Id)
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Keycloak = Pulumi.Keycloak;
return await Deployment.RunAsync(() => 
{
    var masterRealm = Keycloak.GetRealm.Invoke(new()
    {
        Realm = "master",
    });
    // use the keycloak_user data source to grab the admin user's ID
    var defaultAdminUser = Keycloak.GetUser.Invoke(new()
    {
        RealmId = masterRealm.Apply(getRealmResult => getRealmResult.Id),
        Username = "keycloak",
    });
    return new Dictionary<string, object?>
    {
        ["keycloakUserId"] = defaultAdminUser.Apply(getUserResult => getUserResult.Id),
    };
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.keycloak.KeycloakFunctions;
import com.pulumi.keycloak.inputs.GetRealmArgs;
import com.pulumi.keycloak.inputs.GetUserArgs;
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) {
        final var masterRealm = KeycloakFunctions.getRealm(GetRealmArgs.builder()
            .realm("master")
            .build());
        // use the keycloak_user data source to grab the admin user's ID
        final var defaultAdminUser = KeycloakFunctions.getUser(GetUserArgs.builder()
            .realmId(masterRealm.applyValue(getRealmResult -> getRealmResult.id()))
            .username("keycloak")
            .build());
        ctx.export("keycloakUserId", defaultAdminUser.applyValue(getUserResult -> getUserResult.id()));
    }
}
variables:
  masterRealm:
    fn::invoke:
      Function: keycloak:getRealm
      Arguments:
        realm: master
  # use the keycloak_user data source to grab the admin user's ID
  defaultAdminUser:
    fn::invoke:
      Function: keycloak:getUser
      Arguments:
        realmId: ${masterRealm.id}
        username: keycloak
outputs:
  keycloakUserId: ${defaultAdminUser.id}
Using getUser
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getUser(args: GetUserArgs, opts?: InvokeOptions): Promise<GetUserResult>
function getUserOutput(args: GetUserOutputArgs, opts?: InvokeOptions): Output<GetUserResult>def get_user(realm_id: Optional[str] = None,
             username: Optional[str] = None,
             opts: Optional[InvokeOptions] = None) -> GetUserResult
def get_user_output(realm_id: Optional[pulumi.Input[str]] = None,
             username: Optional[pulumi.Input[str]] = None,
             opts: Optional[InvokeOptions] = None) -> Output[GetUserResult]func LookupUser(ctx *Context, args *LookupUserArgs, opts ...InvokeOption) (*LookupUserResult, error)
func LookupUserOutput(ctx *Context, args *LookupUserOutputArgs, opts ...InvokeOption) LookupUserResultOutput> Note: This function is named LookupUser in the Go SDK.
public static class GetUser 
{
    public static Task<GetUserResult> InvokeAsync(GetUserArgs args, InvokeOptions? opts = null)
    public static Output<GetUserResult> Invoke(GetUserInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetUserResult> getUser(GetUserArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: keycloak:index/getUser:getUser
  arguments:
    # arguments dictionaryThe following arguments are supported:
getUser Result
The following output properties are available:
- Attributes Dictionary<string, object>
 - (Computed) A map representing attributes for the user
 - Email string
 - (Computed) The user's email.
 - Email
Verified bool - (Computed) Whether the email address was validated or not. Default to 
false. - Enabled bool
 - (Computed) When false, this user cannot log in. Defaults to 
true. - Federated
Identities List<string> - (Computed) The user's federated identities, if applicable. This block has the following schema:
 - First
Name string - (Computed) The user's first name.
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Last
Name string - (Computed) The user's last name.
 - Realm
Id string - Required
Actions List<string> - Username string
 
- Attributes map[string]interface{}
 - (Computed) A map representing attributes for the user
 - Email string
 - (Computed) The user's email.
 - Email
Verified bool - (Computed) Whether the email address was validated or not. Default to 
false. - Enabled bool
 - (Computed) When false, this user cannot log in. Defaults to 
true. - Federated
Identities []string - (Computed) The user's federated identities, if applicable. This block has the following schema:
 - First
Name string - (Computed) The user's first name.
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Last
Name string - (Computed) The user's last name.
 - Realm
Id string - Required
Actions []string - Username string
 
- attributes Map<String,Object>
 - (Computed) A map representing attributes for the user
 - email String
 - (Computed) The user's email.
 - email
Verified Boolean - (Computed) Whether the email address was validated or not. Default to 
false. - enabled Boolean
 - (Computed) When false, this user cannot log in. Defaults to 
true. - federated
Identities List<String> - (Computed) The user's federated identities, if applicable. This block has the following schema:
 - first
Name String - (Computed) The user's first name.
 - id String
 - The provider-assigned unique ID for this managed resource.
 - last
Name String - (Computed) The user's last name.
 - realm
Id String - required
Actions List<String> - username String
 
- attributes {[key: string]: any}
 - (Computed) A map representing attributes for the user
 - email string
 - (Computed) The user's email.
 - email
Verified boolean - (Computed) Whether the email address was validated or not. Default to 
false. - enabled boolean
 - (Computed) When false, this user cannot log in. Defaults to 
true. - federated
Identities string[] - (Computed) The user's federated identities, if applicable. This block has the following schema:
 - first
Name string - (Computed) The user's first name.
 - id string
 - The provider-assigned unique ID for this managed resource.
 - last
Name string - (Computed) The user's last name.
 - realm
Id string - required
Actions string[] - username string
 
- attributes Mapping[str, Any]
 - (Computed) A map representing attributes for the user
 - email str
 - (Computed) The user's email.
 - email_
verified bool - (Computed) Whether the email address was validated or not. Default to 
false. - enabled bool
 - (Computed) When false, this user cannot log in. Defaults to 
true. - federated_
identities Sequence[str] - (Computed) The user's federated identities, if applicable. This block has the following schema:
 - first_
name str - (Computed) The user's first name.
 - id str
 - The provider-assigned unique ID for this managed resource.
 - last_
name str - (Computed) The user's last name.
 - realm_
id str - required_
actions Sequence[str] - username str
 
- attributes Map<Any>
 - (Computed) A map representing attributes for the user
 - email String
 - (Computed) The user's email.
 - email
Verified Boolean - (Computed) Whether the email address was validated or not. Default to 
false. - enabled Boolean
 - (Computed) When false, this user cannot log in. Defaults to 
true. - federated
Identities List<String> - (Computed) The user's federated identities, if applicable. This block has the following schema:
 - first
Name String - (Computed) The user's first name.
 - id String
 - The provider-assigned unique ID for this managed resource.
 - last
Name String - (Computed) The user's last name.
 - realm
Id String - required
Actions List<String> - username String
 
Package Details
- Repository
 - Keycloak pulumi/pulumi-keycloak
 - License
 - Apache-2.0
 - Notes
 - This Pulumi package is based on the 
keycloakTerraform Provider.