1. Packages
  2. Keycloak Provider
  3. API Docs
  4. RequiredAction
Keycloak v6.4.0 published on Wednesday, Apr 16, 2025 by Pulumi

keycloak.RequiredAction

Explore with Pulumi AI

Allows for creating and managing required actions within Keycloak.

Required actions specify actions required before the first login of all new users.

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 requiredAction = new keycloak.RequiredAction("required_action", {
    realmId: realm.realm,
    alias: "UPDATE_PASSWORD",
    enabled: true,
    name: "Update Password",
    config: {
        max_auth_age: "600",
    },
});
Copy
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    realm="my-realm",
    enabled=True)
required_action = keycloak.RequiredAction("required_action",
    realm_id=realm.realm,
    alias="UPDATE_PASSWORD",
    enabled=True,
    name="Update Password",
    config={
        "max_auth_age": "600",
    })
Copy
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
		}
		_, err = keycloak.NewRequiredAction(ctx, "required_action", &keycloak.RequiredActionArgs{
			RealmId: realm.Realm,
			Alias:   pulumi.String("UPDATE_PASSWORD"),
			Enabled: pulumi.Bool(true),
			Name:    pulumi.String("Update Password"),
			Config: pulumi.StringMap{
				"max_auth_age": pulumi.String("600"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
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 requiredAction = new Keycloak.RequiredAction("required_action", new()
    {
        RealmId = realm.RealmName,
        Alias = "UPDATE_PASSWORD",
        Enabled = true,
        Name = "Update Password",
        Config = 
        {
            { "max_auth_age", "600" },
        },
    });

});
Copy
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.RequiredAction;
import com.pulumi.keycloak.RequiredActionArgs;
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) {
        var realm = new Realm("realm", RealmArgs.builder()
            .realm("my-realm")
            .enabled(true)
            .build());

        var requiredAction = new RequiredAction("requiredAction", RequiredActionArgs.builder()
            .realmId(realm.realm())
            .alias("UPDATE_PASSWORD")
            .enabled(true)
            .name("Update Password")
            .config(Map.of("max_auth_age", "600"))
            .build());

    }
}
Copy
resources:
  realm:
    type: keycloak:Realm
    properties:
      realm: my-realm
      enabled: true
  requiredAction:
    type: keycloak:RequiredAction
    name: required_action
    properties:
      realmId: ${realm.realm}
      alias: UPDATE_PASSWORD
      enabled: true
      name: Update Password
      config:
        max_auth_age: '600'
Copy

Create RequiredAction Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new RequiredAction(name: string, args: RequiredActionArgs, opts?: CustomResourceOptions);
@overload
def RequiredAction(resource_name: str,
                   args: RequiredActionArgs,
                   opts: Optional[ResourceOptions] = None)

@overload
def RequiredAction(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   alias: Optional[str] = None,
                   realm_id: Optional[str] = None,
                   config: Optional[Mapping[str, str]] = None,
                   default_action: Optional[bool] = None,
                   enabled: Optional[bool] = None,
                   name: Optional[str] = None,
                   priority: Optional[int] = None)
func NewRequiredAction(ctx *Context, name string, args RequiredActionArgs, opts ...ResourceOption) (*RequiredAction, error)
public RequiredAction(string name, RequiredActionArgs args, CustomResourceOptions? opts = null)
public RequiredAction(String name, RequiredActionArgs args)
public RequiredAction(String name, RequiredActionArgs args, CustomResourceOptions options)
type: keycloak:RequiredAction
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. RequiredActionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. RequiredActionArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. RequiredActionArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. RequiredActionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. RequiredActionArgs
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 requiredActionResource = new Keycloak.RequiredAction("requiredActionResource", new()
{
    Alias = "string",
    RealmId = "string",
    Config = 
    {
        { "string", "string" },
    },
    DefaultAction = false,
    Enabled = false,
    Name = "string",
    Priority = 0,
});
Copy
example, err := keycloak.NewRequiredAction(ctx, "requiredActionResource", &keycloak.RequiredActionArgs{
	Alias:   pulumi.String("string"),
	RealmId: pulumi.String("string"),
	Config: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	DefaultAction: pulumi.Bool(false),
	Enabled:       pulumi.Bool(false),
	Name:          pulumi.String("string"),
	Priority:      pulumi.Int(0),
})
Copy
var requiredActionResource = new RequiredAction("requiredActionResource", RequiredActionArgs.builder()
    .alias("string")
    .realmId("string")
    .config(Map.of("string", "string"))
    .defaultAction(false)
    .enabled(false)
    .name("string")
    .priority(0)
    .build());
Copy
required_action_resource = keycloak.RequiredAction("requiredActionResource",
    alias="string",
    realm_id="string",
    config={
        "string": "string",
    },
    default_action=False,
    enabled=False,
    name="string",
    priority=0)
Copy
const requiredActionResource = new keycloak.RequiredAction("requiredActionResource", {
    alias: "string",
    realmId: "string",
    config: {
        string: "string",
    },
    defaultAction: false,
    enabled: false,
    name: "string",
    priority: 0,
});
Copy
type: keycloak:RequiredAction
properties:
    alias: string
    config:
        string: string
    defaultAction: false
    enabled: false
    name: string
    priority: 0
    realmId: string
Copy

RequiredAction 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 RequiredAction resource accepts the following input properties:

Alias This property is required. string
The alias of the action to attach as a required action.
RealmId This property is required. string
The realm the required action exists in.
Config Dictionary<string, string>
The configuration. Keys are specific to each configurable required action and not checked when applying.
DefaultAction bool
When true, the required action is set as the default action for new users. Defaults to false.
Enabled bool
When false, the required action is not enabled for new users. Defaults to false.
Name string
The name of the required action.
Priority int
The priority of the required action.
Alias This property is required. string
The alias of the action to attach as a required action.
RealmId This property is required. string
The realm the required action exists in.
Config map[string]string
The configuration. Keys are specific to each configurable required action and not checked when applying.
DefaultAction bool
When true, the required action is set as the default action for new users. Defaults to false.
Enabled bool
When false, the required action is not enabled for new users. Defaults to false.
Name string
The name of the required action.
Priority int
The priority of the required action.
alias This property is required. String
The alias of the action to attach as a required action.
realmId This property is required. String
The realm the required action exists in.
config Map<String,String>
The configuration. Keys are specific to each configurable required action and not checked when applying.
defaultAction Boolean
When true, the required action is set as the default action for new users. Defaults to false.
enabled Boolean
When false, the required action is not enabled for new users. Defaults to false.
name String
The name of the required action.
priority Integer
The priority of the required action.
alias This property is required. string
The alias of the action to attach as a required action.
realmId This property is required. string
The realm the required action exists in.
config {[key: string]: string}
The configuration. Keys are specific to each configurable required action and not checked when applying.
defaultAction boolean
When true, the required action is set as the default action for new users. Defaults to false.
enabled boolean
When false, the required action is not enabled for new users. Defaults to false.
name string
The name of the required action.
priority number
The priority of the required action.
alias This property is required. str
The alias of the action to attach as a required action.
realm_id This property is required. str
The realm the required action exists in.
config Mapping[str, str]
The configuration. Keys are specific to each configurable required action and not checked when applying.
default_action bool
When true, the required action is set as the default action for new users. Defaults to false.
enabled bool
When false, the required action is not enabled for new users. Defaults to false.
name str
The name of the required action.
priority int
The priority of the required action.
alias This property is required. String
The alias of the action to attach as a required action.
realmId This property is required. String
The realm the required action exists in.
config Map<String>
The configuration. Keys are specific to each configurable required action and not checked when applying.
defaultAction Boolean
When true, the required action is set as the default action for new users. Defaults to false.
enabled Boolean
When false, the required action is not enabled for new users. Defaults to false.
name String
The name of the required action.
priority Number
The priority of the required action.

Outputs

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

Look up Existing RequiredAction Resource

Get an existing RequiredAction 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?: RequiredActionState, opts?: CustomResourceOptions): RequiredAction
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        alias: Optional[str] = None,
        config: Optional[Mapping[str, str]] = None,
        default_action: Optional[bool] = None,
        enabled: Optional[bool] = None,
        name: Optional[str] = None,
        priority: Optional[int] = None,
        realm_id: Optional[str] = None) -> RequiredAction
func GetRequiredAction(ctx *Context, name string, id IDInput, state *RequiredActionState, opts ...ResourceOption) (*RequiredAction, error)
public static RequiredAction Get(string name, Input<string> id, RequiredActionState? state, CustomResourceOptions? opts = null)
public static RequiredAction get(String name, Output<String> id, RequiredActionState state, CustomResourceOptions options)
resources:  _:    type: keycloak:RequiredAction    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
Alias string
The alias of the action to attach as a required action.
Config Dictionary<string, string>
The configuration. Keys are specific to each configurable required action and not checked when applying.
DefaultAction bool
When true, the required action is set as the default action for new users. Defaults to false.
Enabled bool
When false, the required action is not enabled for new users. Defaults to false.
Name string
The name of the required action.
Priority int
The priority of the required action.
RealmId string
The realm the required action exists in.
Alias string
The alias of the action to attach as a required action.
Config map[string]string
The configuration. Keys are specific to each configurable required action and not checked when applying.
DefaultAction bool
When true, the required action is set as the default action for new users. Defaults to false.
Enabled bool
When false, the required action is not enabled for new users. Defaults to false.
Name string
The name of the required action.
Priority int
The priority of the required action.
RealmId string
The realm the required action exists in.
alias String
The alias of the action to attach as a required action.
config Map<String,String>
The configuration. Keys are specific to each configurable required action and not checked when applying.
defaultAction Boolean
When true, the required action is set as the default action for new users. Defaults to false.
enabled Boolean
When false, the required action is not enabled for new users. Defaults to false.
name String
The name of the required action.
priority Integer
The priority of the required action.
realmId String
The realm the required action exists in.
alias string
The alias of the action to attach as a required action.
config {[key: string]: string}
The configuration. Keys are specific to each configurable required action and not checked when applying.
defaultAction boolean
When true, the required action is set as the default action for new users. Defaults to false.
enabled boolean
When false, the required action is not enabled for new users. Defaults to false.
name string
The name of the required action.
priority number
The priority of the required action.
realmId string
The realm the required action exists in.
alias str
The alias of the action to attach as a required action.
config Mapping[str, str]
The configuration. Keys are specific to each configurable required action and not checked when applying.
default_action bool
When true, the required action is set as the default action for new users. Defaults to false.
enabled bool
When false, the required action is not enabled for new users. Defaults to false.
name str
The name of the required action.
priority int
The priority of the required action.
realm_id str
The realm the required action exists in.
alias String
The alias of the action to attach as a required action.
config Map<String>
The configuration. Keys are specific to each configurable required action and not checked when applying.
defaultAction Boolean
When true, the required action is set as the default action for new users. Defaults to false.
enabled Boolean
When false, the required action is not enabled for new users. Defaults to false.
name String
The name of the required action.
priority Number
The priority of the required action.
realmId String
The realm the required action exists in.

Import

Authentication executions can be imported using the formats: {{realm}}/{{alias}}.

Example:

bash

$ pulumi import keycloak:index/requiredAction:RequiredAction required_action my-realm/my-default-action-alias
Copy

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 keycloak Terraform Provider.