1. Packages
  2. Keycloak Provider
  3. API Docs
  4. RealmEvents
Keycloak v6.2.1 published on Monday, Feb 3, 2025 by Pulumi

keycloak.RealmEvents

Explore with Pulumi AI

Allows for managing Realm Events settings within Keycloak.

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 realmEvents = new keycloak.RealmEvents("realm_events", {
    realmId: realm.id,
    eventsEnabled: true,
    eventsExpiration: 3600,
    adminEventsEnabled: true,
    adminEventsDetailsEnabled: true,
    enabledEventTypes: [
        "LOGIN",
        "LOGOUT",
    ],
    eventsListeners: ["jboss-logging"],
});
Copy
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    realm="my-realm",
    enabled=True)
realm_events = keycloak.RealmEvents("realm_events",
    realm_id=realm.id,
    events_enabled=True,
    events_expiration=3600,
    admin_events_enabled=True,
    admin_events_details_enabled=True,
    enabled_event_types=[
        "LOGIN",
        "LOGOUT",
    ],
    events_listeners=["jboss-logging"])
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.NewRealmEvents(ctx, "realm_events", &keycloak.RealmEventsArgs{
			RealmId:                   realm.ID(),
			EventsEnabled:             pulumi.Bool(true),
			EventsExpiration:          pulumi.Int(3600),
			AdminEventsEnabled:        pulumi.Bool(true),
			AdminEventsDetailsEnabled: pulumi.Bool(true),
			EnabledEventTypes: pulumi.StringArray{
				pulumi.String("LOGIN"),
				pulumi.String("LOGOUT"),
			},
			EventsListeners: pulumi.StringArray{
				pulumi.String("jboss-logging"),
			},
		})
		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 realmEvents = new Keycloak.RealmEvents("realm_events", new()
    {
        RealmId = realm.Id,
        EventsEnabled = true,
        EventsExpiration = 3600,
        AdminEventsEnabled = true,
        AdminEventsDetailsEnabled = true,
        EnabledEventTypes = new[]
        {
            "LOGIN",
            "LOGOUT",
        },
        EventsListeners = new[]
        {
            "jboss-logging",
        },
    });

});
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.RealmEvents;
import com.pulumi.keycloak.RealmEventsArgs;
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 realmEvents = new RealmEvents("realmEvents", RealmEventsArgs.builder()
            .realmId(realm.id())
            .eventsEnabled(true)
            .eventsExpiration(3600)
            .adminEventsEnabled(true)
            .adminEventsDetailsEnabled(true)
            .enabledEventTypes(            
                "LOGIN",
                "LOGOUT")
            .eventsListeners("jboss-logging")
            .build());

    }
}
Copy
resources:
  realm:
    type: keycloak:Realm
    properties:
      realm: my-realm
      enabled: true
  realmEvents:
    type: keycloak:RealmEvents
    name: realm_events
    properties:
      realmId: ${realm.id}
      eventsEnabled: true
      eventsExpiration: 3600
      adminEventsEnabled: true
      adminEventsDetailsEnabled: true # When omitted or left empty, keycloak will enable all event types
      enabledEventTypes:
        - LOGIN
        - LOGOUT
      eventsListeners:
        - jboss-logging
Copy

Create RealmEvents Resource

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

Constructor syntax

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

@overload
def RealmEvents(resource_name: str,
                opts: Optional[ResourceOptions] = None,
                realm_id: Optional[str] = None,
                admin_events_details_enabled: Optional[bool] = None,
                admin_events_enabled: Optional[bool] = None,
                enabled_event_types: Optional[Sequence[str]] = None,
                events_enabled: Optional[bool] = None,
                events_expiration: Optional[int] = None,
                events_listeners: Optional[Sequence[str]] = None)
func NewRealmEvents(ctx *Context, name string, args RealmEventsArgs, opts ...ResourceOption) (*RealmEvents, error)
public RealmEvents(string name, RealmEventsArgs args, CustomResourceOptions? opts = null)
public RealmEvents(String name, RealmEventsArgs args)
public RealmEvents(String name, RealmEventsArgs args, CustomResourceOptions options)
type: keycloak:RealmEvents
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. RealmEventsArgs
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. RealmEventsArgs
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. RealmEventsArgs
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. RealmEventsArgs
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. RealmEventsArgs
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 realmEventsResource = new Keycloak.RealmEvents("realmEventsResource", new()
{
    RealmId = "string",
    AdminEventsDetailsEnabled = false,
    AdminEventsEnabled = false,
    EnabledEventTypes = new[]
    {
        "string",
    },
    EventsEnabled = false,
    EventsExpiration = 0,
    EventsListeners = new[]
    {
        "string",
    },
});
Copy
example, err := keycloak.NewRealmEvents(ctx, "realmEventsResource", &keycloak.RealmEventsArgs{
	RealmId:                   pulumi.String("string"),
	AdminEventsDetailsEnabled: pulumi.Bool(false),
	AdminEventsEnabled:        pulumi.Bool(false),
	EnabledEventTypes: pulumi.StringArray{
		pulumi.String("string"),
	},
	EventsEnabled:    pulumi.Bool(false),
	EventsExpiration: pulumi.Int(0),
	EventsListeners: pulumi.StringArray{
		pulumi.String("string"),
	},
})
Copy
var realmEventsResource = new RealmEvents("realmEventsResource", RealmEventsArgs.builder()
    .realmId("string")
    .adminEventsDetailsEnabled(false)
    .adminEventsEnabled(false)
    .enabledEventTypes("string")
    .eventsEnabled(false)
    .eventsExpiration(0)
    .eventsListeners("string")
    .build());
Copy
realm_events_resource = keycloak.RealmEvents("realmEventsResource",
    realm_id="string",
    admin_events_details_enabled=False,
    admin_events_enabled=False,
    enabled_event_types=["string"],
    events_enabled=False,
    events_expiration=0,
    events_listeners=["string"])
Copy
const realmEventsResource = new keycloak.RealmEvents("realmEventsResource", {
    realmId: "string",
    adminEventsDetailsEnabled: false,
    adminEventsEnabled: false,
    enabledEventTypes: ["string"],
    eventsEnabled: false,
    eventsExpiration: 0,
    eventsListeners: ["string"],
});
Copy
type: keycloak:RealmEvents
properties:
    adminEventsDetailsEnabled: false
    adminEventsEnabled: false
    enabledEventTypes:
        - string
    eventsEnabled: false
    eventsExpiration: 0
    eventsListeners:
        - string
    realmId: string
Copy

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

RealmId
This property is required.
Changes to this property will trigger replacement.
string
The name of the realm the event settings apply to.
AdminEventsDetailsEnabled bool
When true, saved admin events will included detailed information for create/update requests. Defaults to false.
AdminEventsEnabled bool
When true, admin events are saved to the database, making them available through the admin console. Defaults to false.
EnabledEventTypes List<string>
The event types that will be saved to the database. Omitting this field enables all event types. Defaults to [] or all event types.
EventsEnabled bool
When true, events from enabled_event_types are saved to the database, making them available through the admin console. Defaults to false.
EventsExpiration int
The amount of time in seconds events will be saved in the database. Defaults to 0 or never.
EventsListeners List<string>
The event listeners that events should be sent to. Defaults to [] or none. Note that new realms enable the jboss-logging listener by default, and this resource will remove that unless it is specified.
RealmId
This property is required.
Changes to this property will trigger replacement.
string
The name of the realm the event settings apply to.
AdminEventsDetailsEnabled bool
When true, saved admin events will included detailed information for create/update requests. Defaults to false.
AdminEventsEnabled bool
When true, admin events are saved to the database, making them available through the admin console. Defaults to false.
EnabledEventTypes []string
The event types that will be saved to the database. Omitting this field enables all event types. Defaults to [] or all event types.
EventsEnabled bool
When true, events from enabled_event_types are saved to the database, making them available through the admin console. Defaults to false.
EventsExpiration int
The amount of time in seconds events will be saved in the database. Defaults to 0 or never.
EventsListeners []string
The event listeners that events should be sent to. Defaults to [] or none. Note that new realms enable the jboss-logging listener by default, and this resource will remove that unless it is specified.
realmId
This property is required.
Changes to this property will trigger replacement.
String
The name of the realm the event settings apply to.
adminEventsDetailsEnabled Boolean
When true, saved admin events will included detailed information for create/update requests. Defaults to false.
adminEventsEnabled Boolean
When true, admin events are saved to the database, making them available through the admin console. Defaults to false.
enabledEventTypes List<String>
The event types that will be saved to the database. Omitting this field enables all event types. Defaults to [] or all event types.
eventsEnabled Boolean
When true, events from enabled_event_types are saved to the database, making them available through the admin console. Defaults to false.
eventsExpiration Integer
The amount of time in seconds events will be saved in the database. Defaults to 0 or never.
eventsListeners List<String>
The event listeners that events should be sent to. Defaults to [] or none. Note that new realms enable the jboss-logging listener by default, and this resource will remove that unless it is specified.
realmId
This property is required.
Changes to this property will trigger replacement.
string
The name of the realm the event settings apply to.
adminEventsDetailsEnabled boolean
When true, saved admin events will included detailed information for create/update requests. Defaults to false.
adminEventsEnabled boolean
When true, admin events are saved to the database, making them available through the admin console. Defaults to false.
enabledEventTypes string[]
The event types that will be saved to the database. Omitting this field enables all event types. Defaults to [] or all event types.
eventsEnabled boolean
When true, events from enabled_event_types are saved to the database, making them available through the admin console. Defaults to false.
eventsExpiration number
The amount of time in seconds events will be saved in the database. Defaults to 0 or never.
eventsListeners string[]
The event listeners that events should be sent to. Defaults to [] or none. Note that new realms enable the jboss-logging listener by default, and this resource will remove that unless it is specified.
realm_id
This property is required.
Changes to this property will trigger replacement.
str
The name of the realm the event settings apply to.
admin_events_details_enabled bool
When true, saved admin events will included detailed information for create/update requests. Defaults to false.
admin_events_enabled bool
When true, admin events are saved to the database, making them available through the admin console. Defaults to false.
enabled_event_types Sequence[str]
The event types that will be saved to the database. Omitting this field enables all event types. Defaults to [] or all event types.
events_enabled bool
When true, events from enabled_event_types are saved to the database, making them available through the admin console. Defaults to false.
events_expiration int
The amount of time in seconds events will be saved in the database. Defaults to 0 or never.
events_listeners Sequence[str]
The event listeners that events should be sent to. Defaults to [] or none. Note that new realms enable the jboss-logging listener by default, and this resource will remove that unless it is specified.
realmId
This property is required.
Changes to this property will trigger replacement.
String
The name of the realm the event settings apply to.
adminEventsDetailsEnabled Boolean
When true, saved admin events will included detailed information for create/update requests. Defaults to false.
adminEventsEnabled Boolean
When true, admin events are saved to the database, making them available through the admin console. Defaults to false.
enabledEventTypes List<String>
The event types that will be saved to the database. Omitting this field enables all event types. Defaults to [] or all event types.
eventsEnabled Boolean
When true, events from enabled_event_types are saved to the database, making them available through the admin console. Defaults to false.
eventsExpiration Number
The amount of time in seconds events will be saved in the database. Defaults to 0 or never.
eventsListeners List<String>
The event listeners that events should be sent to. Defaults to [] or none. Note that new realms enable the jboss-logging listener by default, and this resource will remove that unless it is specified.

Outputs

All input properties are implicitly available as output properties. Additionally, the RealmEvents 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 RealmEvents Resource

Get an existing RealmEvents 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?: RealmEventsState, opts?: CustomResourceOptions): RealmEvents
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        admin_events_details_enabled: Optional[bool] = None,
        admin_events_enabled: Optional[bool] = None,
        enabled_event_types: Optional[Sequence[str]] = None,
        events_enabled: Optional[bool] = None,
        events_expiration: Optional[int] = None,
        events_listeners: Optional[Sequence[str]] = None,
        realm_id: Optional[str] = None) -> RealmEvents
func GetRealmEvents(ctx *Context, name string, id IDInput, state *RealmEventsState, opts ...ResourceOption) (*RealmEvents, error)
public static RealmEvents Get(string name, Input<string> id, RealmEventsState? state, CustomResourceOptions? opts = null)
public static RealmEvents get(String name, Output<String> id, RealmEventsState state, CustomResourceOptions options)
resources:  _:    type: keycloak:RealmEvents    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:
AdminEventsDetailsEnabled bool
When true, saved admin events will included detailed information for create/update requests. Defaults to false.
AdminEventsEnabled bool
When true, admin events are saved to the database, making them available through the admin console. Defaults to false.
EnabledEventTypes List<string>
The event types that will be saved to the database. Omitting this field enables all event types. Defaults to [] or all event types.
EventsEnabled bool
When true, events from enabled_event_types are saved to the database, making them available through the admin console. Defaults to false.
EventsExpiration int
The amount of time in seconds events will be saved in the database. Defaults to 0 or never.
EventsListeners List<string>
The event listeners that events should be sent to. Defaults to [] or none. Note that new realms enable the jboss-logging listener by default, and this resource will remove that unless it is specified.
RealmId Changes to this property will trigger replacement. string
The name of the realm the event settings apply to.
AdminEventsDetailsEnabled bool
When true, saved admin events will included detailed information for create/update requests. Defaults to false.
AdminEventsEnabled bool
When true, admin events are saved to the database, making them available through the admin console. Defaults to false.
EnabledEventTypes []string
The event types that will be saved to the database. Omitting this field enables all event types. Defaults to [] or all event types.
EventsEnabled bool
When true, events from enabled_event_types are saved to the database, making them available through the admin console. Defaults to false.
EventsExpiration int
The amount of time in seconds events will be saved in the database. Defaults to 0 or never.
EventsListeners []string
The event listeners that events should be sent to. Defaults to [] or none. Note that new realms enable the jboss-logging listener by default, and this resource will remove that unless it is specified.
RealmId Changes to this property will trigger replacement. string
The name of the realm the event settings apply to.
adminEventsDetailsEnabled Boolean
When true, saved admin events will included detailed information for create/update requests. Defaults to false.
adminEventsEnabled Boolean
When true, admin events are saved to the database, making them available through the admin console. Defaults to false.
enabledEventTypes List<String>
The event types that will be saved to the database. Omitting this field enables all event types. Defaults to [] or all event types.
eventsEnabled Boolean
When true, events from enabled_event_types are saved to the database, making them available through the admin console. Defaults to false.
eventsExpiration Integer
The amount of time in seconds events will be saved in the database. Defaults to 0 or never.
eventsListeners List<String>
The event listeners that events should be sent to. Defaults to [] or none. Note that new realms enable the jboss-logging listener by default, and this resource will remove that unless it is specified.
realmId Changes to this property will trigger replacement. String
The name of the realm the event settings apply to.
adminEventsDetailsEnabled boolean
When true, saved admin events will included detailed information for create/update requests. Defaults to false.
adminEventsEnabled boolean
When true, admin events are saved to the database, making them available through the admin console. Defaults to false.
enabledEventTypes string[]
The event types that will be saved to the database. Omitting this field enables all event types. Defaults to [] or all event types.
eventsEnabled boolean
When true, events from enabled_event_types are saved to the database, making them available through the admin console. Defaults to false.
eventsExpiration number
The amount of time in seconds events will be saved in the database. Defaults to 0 or never.
eventsListeners string[]
The event listeners that events should be sent to. Defaults to [] or none. Note that new realms enable the jboss-logging listener by default, and this resource will remove that unless it is specified.
realmId Changes to this property will trigger replacement. string
The name of the realm the event settings apply to.
admin_events_details_enabled bool
When true, saved admin events will included detailed information for create/update requests. Defaults to false.
admin_events_enabled bool
When true, admin events are saved to the database, making them available through the admin console. Defaults to false.
enabled_event_types Sequence[str]
The event types that will be saved to the database. Omitting this field enables all event types. Defaults to [] or all event types.
events_enabled bool
When true, events from enabled_event_types are saved to the database, making them available through the admin console. Defaults to false.
events_expiration int
The amount of time in seconds events will be saved in the database. Defaults to 0 or never.
events_listeners Sequence[str]
The event listeners that events should be sent to. Defaults to [] or none. Note that new realms enable the jboss-logging listener by default, and this resource will remove that unless it is specified.
realm_id Changes to this property will trigger replacement. str
The name of the realm the event settings apply to.
adminEventsDetailsEnabled Boolean
When true, saved admin events will included detailed information for create/update requests. Defaults to false.
adminEventsEnabled Boolean
When true, admin events are saved to the database, making them available through the admin console. Defaults to false.
enabledEventTypes List<String>
The event types that will be saved to the database. Omitting this field enables all event types. Defaults to [] or all event types.
eventsEnabled Boolean
When true, events from enabled_event_types are saved to the database, making them available through the admin console. Defaults to false.
eventsExpiration Number
The amount of time in seconds events will be saved in the database. Defaults to 0 or never.
eventsListeners List<String>
The event listeners that events should be sent to. Defaults to [] or none. Note that new realms enable the jboss-logging listener by default, and this resource will remove that unless it is specified.
realmId Changes to this property will trigger replacement. String
The name of the realm the event settings apply to.

Import

This resource currently does not support importing.

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.