1. Packages
  2. Keycloak
  3. API Docs
  4. GenericClientRoleMapper
Keycloak v5.3.2 published on Friday, May 10, 2024 by Pulumi

keycloak.GenericClientRoleMapper

Explore with Pulumi AI

keycloak logo
Keycloak v5.3.2 published on Friday, May 10, 2024 by Pulumi

    !> WARNING: This resource is deprecated and will be removed in the next major version. Please use keycloak.GenericRoleMapper instead.

    Allow for creating and managing a client’s scope mappings within Keycloak.

    By default, all the user role mappings of the user are added as claims within the token (OIDC) or assertion (SAML). When full_scope_allowed is set to false for a client, role scope mapping allows you to limit the roles that get declared inside an access token for a client.

    Example Usage

    Realm Role To Client)

    import * as pulumi from "@pulumi/pulumi";
    import * as keycloak from "@pulumi/keycloak";
    
    const realm = new keycloak.Realm("realm", {
        realm: "my-realm",
        enabled: true,
    });
    const client = new keycloak.openid.Client("client", {
        realmId: realm.id,
        clientId: "client",
        name: "client",
        enabled: true,
        accessType: "BEARER-ONLY",
    });
    const realmRole = new keycloak.Role("realm_role", {
        realmId: realm.id,
        name: "my-realm-role",
        description: "My Realm Role",
    });
    const clientRoleMapper = new keycloak.GenericClientRoleMapper("client_role_mapper", {
        realmId: realm.id,
        clientId: client.id,
        roleId: realmRole.id,
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    client = keycloak.openid.Client("client",
        realm_id=realm.id,
        client_id="client",
        name="client",
        enabled=True,
        access_type="BEARER-ONLY")
    realm_role = keycloak.Role("realm_role",
        realm_id=realm.id,
        name="my-realm-role",
        description="My Realm Role")
    client_role_mapper = keycloak.GenericClientRoleMapper("client_role_mapper",
        realm_id=realm.id,
        client_id=client.id,
        role_id=realm_role.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak/openid"
    	"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
    		}
    		client, err := openid.NewClient(ctx, "client", &openid.ClientArgs{
    			RealmId:    realm.ID(),
    			ClientId:   pulumi.String("client"),
    			Name:       pulumi.String("client"),
    			Enabled:    pulumi.Bool(true),
    			AccessType: pulumi.String("BEARER-ONLY"),
    		})
    		if err != nil {
    			return err
    		}
    		realmRole, err := keycloak.NewRole(ctx, "realm_role", &keycloak.RoleArgs{
    			RealmId:     realm.ID(),
    			Name:        pulumi.String("my-realm-role"),
    			Description: pulumi.String("My Realm Role"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewGenericClientRoleMapper(ctx, "client_role_mapper", &keycloak.GenericClientRoleMapperArgs{
    			RealmId:  realm.ID(),
    			ClientId: client.ID(),
    			RoleId:   realmRole.ID(),
    		})
    		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 client = new Keycloak.OpenId.Client("client", new()
        {
            RealmId = realm.Id,
            ClientId = "client",
            Name = "client",
            Enabled = true,
            AccessType = "BEARER-ONLY",
        });
    
        var realmRole = new Keycloak.Role("realm_role", new()
        {
            RealmId = realm.Id,
            Name = "my-realm-role",
            Description = "My Realm Role",
        });
    
        var clientRoleMapper = new Keycloak.GenericClientRoleMapper("client_role_mapper", new()
        {
            RealmId = realm.Id,
            ClientId = client.Id,
            RoleId = realmRole.Id,
        });
    
    });
    
    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.openid.Client;
    import com.pulumi.keycloak.openid.ClientArgs;
    import com.pulumi.keycloak.Role;
    import com.pulumi.keycloak.RoleArgs;
    import com.pulumi.keycloak.GenericClientRoleMapper;
    import com.pulumi.keycloak.GenericClientRoleMapperArgs;
    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 client = new Client("client", ClientArgs.builder()        
                .realmId(realm.id())
                .clientId("client")
                .name("client")
                .enabled(true)
                .accessType("BEARER-ONLY")
                .build());
    
            var realmRole = new Role("realmRole", RoleArgs.builder()        
                .realmId(realm.id())
                .name("my-realm-role")
                .description("My Realm Role")
                .build());
    
            var clientRoleMapper = new GenericClientRoleMapper("clientRoleMapper", GenericClientRoleMapperArgs.builder()        
                .realmId(realm.id())
                .clientId(client.id())
                .roleId(realmRole.id())
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      client:
        type: keycloak:openid:Client
        properties:
          realmId: ${realm.id}
          clientId: client
          name: client
          enabled: true
          accessType: BEARER-ONLY
      realmRole:
        type: keycloak:Role
        name: realm_role
        properties:
          realmId: ${realm.id}
          name: my-realm-role
          description: My Realm Role
      clientRoleMapper:
        type: keycloak:GenericClientRoleMapper
        name: client_role_mapper
        properties:
          realmId: ${realm.id}
          clientId: ${client.id}
          roleId: ${realmRole.id}
    

    Client Role To Client)

    import * as pulumi from "@pulumi/pulumi";
    import * as keycloak from "@pulumi/keycloak";
    
    const realm = new keycloak.Realm("realm", {
        realm: "my-realm",
        enabled: true,
    });
    const clientA = new keycloak.openid.Client("client_a", {
        realmId: realm.id,
        clientId: "client-a",
        name: "client-a",
        enabled: true,
        accessType: "BEARER-ONLY",
        fullScopeAllowed: false,
    });
    const clientRoleA = new keycloak.Role("client_role_a", {
        realmId: realm.id,
        clientId: clientA.id,
        name: "my-client-role",
        description: "My Client Role",
    });
    const clientB = new keycloak.openid.Client("client_b", {
        realmId: realm.id,
        clientId: "client-b",
        name: "client-b",
        enabled: true,
        accessType: "BEARER-ONLY",
    });
    const clientRoleB = new keycloak.Role("client_role_b", {
        realmId: realm.id,
        clientId: clientB.id,
        name: "my-client-role",
        description: "My Client Role",
    });
    const clientBRoleMapper = new keycloak.GenericClientRoleMapper("client_b_role_mapper", {
        realmId: realm.id,
        clientId: clientB.id,
        roleId: clientRoleA.id,
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    client_a = keycloak.openid.Client("client_a",
        realm_id=realm.id,
        client_id="client-a",
        name="client-a",
        enabled=True,
        access_type="BEARER-ONLY",
        full_scope_allowed=False)
    client_role_a = keycloak.Role("client_role_a",
        realm_id=realm.id,
        client_id=client_a.id,
        name="my-client-role",
        description="My Client Role")
    client_b = keycloak.openid.Client("client_b",
        realm_id=realm.id,
        client_id="client-b",
        name="client-b",
        enabled=True,
        access_type="BEARER-ONLY")
    client_role_b = keycloak.Role("client_role_b",
        realm_id=realm.id,
        client_id=client_b.id,
        name="my-client-role",
        description="My Client Role")
    client_b_role_mapper = keycloak.GenericClientRoleMapper("client_b_role_mapper",
        realm_id=realm.id,
        client_id=client_b.id,
        role_id=client_role_a.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak/openid"
    	"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
    		}
    		clientA, err := openid.NewClient(ctx, "client_a", &openid.ClientArgs{
    			RealmId:          realm.ID(),
    			ClientId:         pulumi.String("client-a"),
    			Name:             pulumi.String("client-a"),
    			Enabled:          pulumi.Bool(true),
    			AccessType:       pulumi.String("BEARER-ONLY"),
    			FullScopeAllowed: pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		clientRoleA, err := keycloak.NewRole(ctx, "client_role_a", &keycloak.RoleArgs{
    			RealmId:     realm.ID(),
    			ClientId:    clientA.ID(),
    			Name:        pulumi.String("my-client-role"),
    			Description: pulumi.String("My Client Role"),
    		})
    		if err != nil {
    			return err
    		}
    		clientB, err := openid.NewClient(ctx, "client_b", &openid.ClientArgs{
    			RealmId:    realm.ID(),
    			ClientId:   pulumi.String("client-b"),
    			Name:       pulumi.String("client-b"),
    			Enabled:    pulumi.Bool(true),
    			AccessType: pulumi.String("BEARER-ONLY"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewRole(ctx, "client_role_b", &keycloak.RoleArgs{
    			RealmId:     realm.ID(),
    			ClientId:    clientB.ID(),
    			Name:        pulumi.String("my-client-role"),
    			Description: pulumi.String("My Client Role"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewGenericClientRoleMapper(ctx, "client_b_role_mapper", &keycloak.GenericClientRoleMapperArgs{
    			RealmId:  realm.ID(),
    			ClientId: clientB.ID(),
    			RoleId:   clientRoleA.ID(),
    		})
    		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 clientA = new Keycloak.OpenId.Client("client_a", new()
        {
            RealmId = realm.Id,
            ClientId = "client-a",
            Name = "client-a",
            Enabled = true,
            AccessType = "BEARER-ONLY",
            FullScopeAllowed = false,
        });
    
        var clientRoleA = new Keycloak.Role("client_role_a", new()
        {
            RealmId = realm.Id,
            ClientId = clientA.Id,
            Name = "my-client-role",
            Description = "My Client Role",
        });
    
        var clientB = new Keycloak.OpenId.Client("client_b", new()
        {
            RealmId = realm.Id,
            ClientId = "client-b",
            Name = "client-b",
            Enabled = true,
            AccessType = "BEARER-ONLY",
        });
    
        var clientRoleB = new Keycloak.Role("client_role_b", new()
        {
            RealmId = realm.Id,
            ClientId = clientB.Id,
            Name = "my-client-role",
            Description = "My Client Role",
        });
    
        var clientBRoleMapper = new Keycloak.GenericClientRoleMapper("client_b_role_mapper", new()
        {
            RealmId = realm.Id,
            ClientId = clientB.Id,
            RoleId = clientRoleA.Id,
        });
    
    });
    
    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.openid.Client;
    import com.pulumi.keycloak.openid.ClientArgs;
    import com.pulumi.keycloak.Role;
    import com.pulumi.keycloak.RoleArgs;
    import com.pulumi.keycloak.GenericClientRoleMapper;
    import com.pulumi.keycloak.GenericClientRoleMapperArgs;
    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 clientA = new Client("clientA", ClientArgs.builder()        
                .realmId(realm.id())
                .clientId("client-a")
                .name("client-a")
                .enabled(true)
                .accessType("BEARER-ONLY")
                .fullScopeAllowed(false)
                .build());
    
            var clientRoleA = new Role("clientRoleA", RoleArgs.builder()        
                .realmId(realm.id())
                .clientId(clientA.id())
                .name("my-client-role")
                .description("My Client Role")
                .build());
    
            var clientB = new Client("clientB", ClientArgs.builder()        
                .realmId(realm.id())
                .clientId("client-b")
                .name("client-b")
                .enabled(true)
                .accessType("BEARER-ONLY")
                .build());
    
            var clientRoleB = new Role("clientRoleB", RoleArgs.builder()        
                .realmId(realm.id())
                .clientId(clientB.id())
                .name("my-client-role")
                .description("My Client Role")
                .build());
    
            var clientBRoleMapper = new GenericClientRoleMapper("clientBRoleMapper", GenericClientRoleMapperArgs.builder()        
                .realmId(realm.id())
                .clientId(clientB.id())
                .roleId(clientRoleA.id())
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      clientA:
        type: keycloak:openid:Client
        name: client_a
        properties:
          realmId: ${realm.id}
          clientId: client-a
          name: client-a
          enabled: true
          accessType: BEARER-ONLY
          fullScopeAllowed: false
      clientRoleA:
        type: keycloak:Role
        name: client_role_a
        properties:
          realmId: ${realm.id}
          clientId: ${clientA.id}
          name: my-client-role
          description: My Client Role
      clientB:
        type: keycloak:openid:Client
        name: client_b
        properties:
          realmId: ${realm.id}
          clientId: client-b
          name: client-b
          enabled: true
          accessType: BEARER-ONLY
      clientRoleB:
        type: keycloak:Role
        name: client_role_b
        properties:
          realmId: ${realm.id}
          clientId: ${clientB.id}
          name: my-client-role
          description: My Client Role
      clientBRoleMapper:
        type: keycloak:GenericClientRoleMapper
        name: client_b_role_mapper
        properties:
          realmId: ${realm.id}
          clientId: ${clientB.id}
          roleId: ${clientRoleA.id}
    

    Realm Role To Client Scope)

    import * as pulumi from "@pulumi/pulumi";
    import * as keycloak from "@pulumi/keycloak";
    
    const realm = new keycloak.Realm("realm", {
        realm: "my-realm",
        enabled: true,
    });
    const clientScope = new keycloak.openid.ClientScope("client_scope", {
        realmId: realm.id,
        name: "my-client-scope",
    });
    const realmRole = new keycloak.Role("realm_role", {
        realmId: realm.id,
        name: "my-realm-role",
        description: "My Realm Role",
    });
    const clientRoleMapper = new keycloak.GenericClientRoleMapper("client_role_mapper", {
        realmId: realm.id,
        clientScopeId: clientScope.id,
        roleId: realmRole.id,
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    client_scope = keycloak.openid.ClientScope("client_scope",
        realm_id=realm.id,
        name="my-client-scope")
    realm_role = keycloak.Role("realm_role",
        realm_id=realm.id,
        name="my-realm-role",
        description="My Realm Role")
    client_role_mapper = keycloak.GenericClientRoleMapper("client_role_mapper",
        realm_id=realm.id,
        client_scope_id=client_scope.id,
        role_id=realm_role.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak/openid"
    	"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
    		}
    		clientScope, err := openid.NewClientScope(ctx, "client_scope", &openid.ClientScopeArgs{
    			RealmId: realm.ID(),
    			Name:    pulumi.String("my-client-scope"),
    		})
    		if err != nil {
    			return err
    		}
    		realmRole, err := keycloak.NewRole(ctx, "realm_role", &keycloak.RoleArgs{
    			RealmId:     realm.ID(),
    			Name:        pulumi.String("my-realm-role"),
    			Description: pulumi.String("My Realm Role"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewGenericClientRoleMapper(ctx, "client_role_mapper", &keycloak.GenericClientRoleMapperArgs{
    			RealmId:       realm.ID(),
    			ClientScopeId: clientScope.ID(),
    			RoleId:        realmRole.ID(),
    		})
    		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 clientScope = new Keycloak.OpenId.ClientScope("client_scope", new()
        {
            RealmId = realm.Id,
            Name = "my-client-scope",
        });
    
        var realmRole = new Keycloak.Role("realm_role", new()
        {
            RealmId = realm.Id,
            Name = "my-realm-role",
            Description = "My Realm Role",
        });
    
        var clientRoleMapper = new Keycloak.GenericClientRoleMapper("client_role_mapper", new()
        {
            RealmId = realm.Id,
            ClientScopeId = clientScope.Id,
            RoleId = realmRole.Id,
        });
    
    });
    
    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.openid.ClientScope;
    import com.pulumi.keycloak.openid.ClientScopeArgs;
    import com.pulumi.keycloak.Role;
    import com.pulumi.keycloak.RoleArgs;
    import com.pulumi.keycloak.GenericClientRoleMapper;
    import com.pulumi.keycloak.GenericClientRoleMapperArgs;
    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 clientScope = new ClientScope("clientScope", ClientScopeArgs.builder()        
                .realmId(realm.id())
                .name("my-client-scope")
                .build());
    
            var realmRole = new Role("realmRole", RoleArgs.builder()        
                .realmId(realm.id())
                .name("my-realm-role")
                .description("My Realm Role")
                .build());
    
            var clientRoleMapper = new GenericClientRoleMapper("clientRoleMapper", GenericClientRoleMapperArgs.builder()        
                .realmId(realm.id())
                .clientScopeId(clientScope.id())
                .roleId(realmRole.id())
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      clientScope:
        type: keycloak:openid:ClientScope
        name: client_scope
        properties:
          realmId: ${realm.id}
          name: my-client-scope
      realmRole:
        type: keycloak:Role
        name: realm_role
        properties:
          realmId: ${realm.id}
          name: my-realm-role
          description: My Realm Role
      clientRoleMapper:
        type: keycloak:GenericClientRoleMapper
        name: client_role_mapper
        properties:
          realmId: ${realm.id}
          clientScopeId: ${clientScope.id}
          roleId: ${realmRole.id}
    

    Client Role To Client Scope)

    import * as pulumi from "@pulumi/pulumi";
    import * as keycloak from "@pulumi/keycloak";
    
    const realm = new keycloak.Realm("realm", {
        realm: "my-realm",
        enabled: true,
    });
    const client = new keycloak.openid.Client("client", {
        realmId: realm.id,
        clientId: "client",
        name: "client",
        enabled: true,
        accessType: "BEARER-ONLY",
    });
    const clientRole = new keycloak.Role("client_role", {
        realmId: realm.id,
        clientId: client.id,
        name: "my-client-role",
        description: "My Client Role",
    });
    const clientScope = new keycloak.openid.ClientScope("client_scope", {
        realmId: realm.id,
        name: "my-client-scope",
    });
    const clientBRoleMapper = new keycloak.GenericClientRoleMapper("client_b_role_mapper", {
        realmId: realm.id,
        clientScopeId: clientScope.id,
        roleId: clientRole.id,
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    client = keycloak.openid.Client("client",
        realm_id=realm.id,
        client_id="client",
        name="client",
        enabled=True,
        access_type="BEARER-ONLY")
    client_role = keycloak.Role("client_role",
        realm_id=realm.id,
        client_id=client.id,
        name="my-client-role",
        description="My Client Role")
    client_scope = keycloak.openid.ClientScope("client_scope",
        realm_id=realm.id,
        name="my-client-scope")
    client_b_role_mapper = keycloak.GenericClientRoleMapper("client_b_role_mapper",
        realm_id=realm.id,
        client_scope_id=client_scope.id,
        role_id=client_role.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak/openid"
    	"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
    		}
    		client, err := openid.NewClient(ctx, "client", &openid.ClientArgs{
    			RealmId:    realm.ID(),
    			ClientId:   pulumi.String("client"),
    			Name:       pulumi.String("client"),
    			Enabled:    pulumi.Bool(true),
    			AccessType: pulumi.String("BEARER-ONLY"),
    		})
    		if err != nil {
    			return err
    		}
    		clientRole, err := keycloak.NewRole(ctx, "client_role", &keycloak.RoleArgs{
    			RealmId:     realm.ID(),
    			ClientId:    client.ID(),
    			Name:        pulumi.String("my-client-role"),
    			Description: pulumi.String("My Client Role"),
    		})
    		if err != nil {
    			return err
    		}
    		clientScope, err := openid.NewClientScope(ctx, "client_scope", &openid.ClientScopeArgs{
    			RealmId: realm.ID(),
    			Name:    pulumi.String("my-client-scope"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewGenericClientRoleMapper(ctx, "client_b_role_mapper", &keycloak.GenericClientRoleMapperArgs{
    			RealmId:       realm.ID(),
    			ClientScopeId: clientScope.ID(),
    			RoleId:        clientRole.ID(),
    		})
    		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 client = new Keycloak.OpenId.Client("client", new()
        {
            RealmId = realm.Id,
            ClientId = "client",
            Name = "client",
            Enabled = true,
            AccessType = "BEARER-ONLY",
        });
    
        var clientRole = new Keycloak.Role("client_role", new()
        {
            RealmId = realm.Id,
            ClientId = client.Id,
            Name = "my-client-role",
            Description = "My Client Role",
        });
    
        var clientScope = new Keycloak.OpenId.ClientScope("client_scope", new()
        {
            RealmId = realm.Id,
            Name = "my-client-scope",
        });
    
        var clientBRoleMapper = new Keycloak.GenericClientRoleMapper("client_b_role_mapper", new()
        {
            RealmId = realm.Id,
            ClientScopeId = clientScope.Id,
            RoleId = clientRole.Id,
        });
    
    });
    
    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.openid.Client;
    import com.pulumi.keycloak.openid.ClientArgs;
    import com.pulumi.keycloak.Role;
    import com.pulumi.keycloak.RoleArgs;
    import com.pulumi.keycloak.openid.ClientScope;
    import com.pulumi.keycloak.openid.ClientScopeArgs;
    import com.pulumi.keycloak.GenericClientRoleMapper;
    import com.pulumi.keycloak.GenericClientRoleMapperArgs;
    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 client = new Client("client", ClientArgs.builder()        
                .realmId(realm.id())
                .clientId("client")
                .name("client")
                .enabled(true)
                .accessType("BEARER-ONLY")
                .build());
    
            var clientRole = new Role("clientRole", RoleArgs.builder()        
                .realmId(realm.id())
                .clientId(client.id())
                .name("my-client-role")
                .description("My Client Role")
                .build());
    
            var clientScope = new ClientScope("clientScope", ClientScopeArgs.builder()        
                .realmId(realm.id())
                .name("my-client-scope")
                .build());
    
            var clientBRoleMapper = new GenericClientRoleMapper("clientBRoleMapper", GenericClientRoleMapperArgs.builder()        
                .realmId(realm.id())
                .clientScopeId(clientScope.id())
                .roleId(clientRole.id())
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      client:
        type: keycloak:openid:Client
        properties:
          realmId: ${realm.id}
          clientId: client
          name: client
          enabled: true
          accessType: BEARER-ONLY
      clientRole:
        type: keycloak:Role
        name: client_role
        properties:
          realmId: ${realm.id}
          clientId: ${client.id}
          name: my-client-role
          description: My Client Role
      clientScope:
        type: keycloak:openid:ClientScope
        name: client_scope
        properties:
          realmId: ${realm.id}
          name: my-client-scope
      clientBRoleMapper:
        type: keycloak:GenericClientRoleMapper
        name: client_b_role_mapper
        properties:
          realmId: ${realm.id}
          clientScopeId: ${clientScope.id}
          roleId: ${clientRole.id}
    

    Create GenericClientRoleMapper Resource

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

    Constructor syntax

    new GenericClientRoleMapper(name: string, args: GenericClientRoleMapperArgs, opts?: CustomResourceOptions);
    @overload
    def GenericClientRoleMapper(resource_name: str,
                                args: GenericClientRoleMapperArgs,
                                opts: Optional[ResourceOptions] = None)
    
    @overload
    def GenericClientRoleMapper(resource_name: str,
                                opts: Optional[ResourceOptions] = None,
                                realm_id: Optional[str] = None,
                                role_id: Optional[str] = None,
                                client_id: Optional[str] = None,
                                client_scope_id: Optional[str] = None)
    func NewGenericClientRoleMapper(ctx *Context, name string, args GenericClientRoleMapperArgs, opts ...ResourceOption) (*GenericClientRoleMapper, error)
    public GenericClientRoleMapper(string name, GenericClientRoleMapperArgs args, CustomResourceOptions? opts = null)
    public GenericClientRoleMapper(String name, GenericClientRoleMapperArgs args)
    public GenericClientRoleMapper(String name, GenericClientRoleMapperArgs args, CustomResourceOptions options)
    
    type: keycloak:GenericClientRoleMapper
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args GenericClientRoleMapperArgs
    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 GenericClientRoleMapperArgs
    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 GenericClientRoleMapperArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args GenericClientRoleMapperArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args GenericClientRoleMapperArgs
    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 genericClientRoleMapperResource = new Keycloak.GenericClientRoleMapper("genericClientRoleMapperResource", new()
    {
        RealmId = "string",
        RoleId = "string",
        ClientId = "string",
        ClientScopeId = "string",
    });
    
    example, err := keycloak.NewGenericClientRoleMapper(ctx, "genericClientRoleMapperResource", &keycloak.GenericClientRoleMapperArgs{
    	RealmId:       pulumi.String("string"),
    	RoleId:        pulumi.String("string"),
    	ClientId:      pulumi.String("string"),
    	ClientScopeId: pulumi.String("string"),
    })
    
    var genericClientRoleMapperResource = new GenericClientRoleMapper("genericClientRoleMapperResource", GenericClientRoleMapperArgs.builder()
        .realmId("string")
        .roleId("string")
        .clientId("string")
        .clientScopeId("string")
        .build());
    
    generic_client_role_mapper_resource = keycloak.GenericClientRoleMapper("genericClientRoleMapperResource",
        realm_id="string",
        role_id="string",
        client_id="string",
        client_scope_id="string")
    
    const genericClientRoleMapperResource = new keycloak.GenericClientRoleMapper("genericClientRoleMapperResource", {
        realmId: "string",
        roleId: "string",
        clientId: "string",
        clientScopeId: "string",
    });
    
    type: keycloak:GenericClientRoleMapper
    properties:
        clientId: string
        clientScopeId: string
        realmId: string
        roleId: string
    

    GenericClientRoleMapper Resource Properties

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

    Inputs

    The GenericClientRoleMapper resource accepts the following input properties:

    RealmId string
    The realm this role mapper exists within.
    RoleId string
    The ID of the role to be added to this role mapper.
    ClientId string
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    ClientScopeId string
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    RealmId string
    The realm this role mapper exists within.
    RoleId string
    The ID of the role to be added to this role mapper.
    ClientId string
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    ClientScopeId string
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realmId String
    The realm this role mapper exists within.
    roleId String
    The ID of the role to be added to this role mapper.
    clientId String
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId String
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realmId string
    The realm this role mapper exists within.
    roleId string
    The ID of the role to be added to this role mapper.
    clientId string
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId string
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realm_id str
    The realm this role mapper exists within.
    role_id str
    The ID of the role to be added to this role mapper.
    client_id str
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    client_scope_id str
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realmId String
    The realm this role mapper exists within.
    roleId String
    The ID of the role to be added to this role mapper.
    clientId String
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId String
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.

    Outputs

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

    Get an existing GenericClientRoleMapper 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?: GenericClientRoleMapperState, opts?: CustomResourceOptions): GenericClientRoleMapper
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            client_id: Optional[str] = None,
            client_scope_id: Optional[str] = None,
            realm_id: Optional[str] = None,
            role_id: Optional[str] = None) -> GenericClientRoleMapper
    func GetGenericClientRoleMapper(ctx *Context, name string, id IDInput, state *GenericClientRoleMapperState, opts ...ResourceOption) (*GenericClientRoleMapper, error)
    public static GenericClientRoleMapper Get(string name, Input<string> id, GenericClientRoleMapperState? state, CustomResourceOptions? opts = null)
    public static GenericClientRoleMapper get(String name, Output<String> id, GenericClientRoleMapperState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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.
    The following state arguments are supported:
    ClientId string
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    ClientScopeId string
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    RealmId string
    The realm this role mapper exists within.
    RoleId string
    The ID of the role to be added to this role mapper.
    ClientId string
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    ClientScopeId string
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    RealmId string
    The realm this role mapper exists within.
    RoleId string
    The ID of the role to be added to this role mapper.
    clientId String
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId String
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realmId String
    The realm this role mapper exists within.
    roleId String
    The ID of the role to be added to this role mapper.
    clientId string
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId string
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realmId string
    The realm this role mapper exists within.
    roleId string
    The ID of the role to be added to this role mapper.
    client_id str
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    client_scope_id str
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realm_id str
    The realm this role mapper exists within.
    role_id str
    The ID of the role to be added to this role mapper.
    clientId String
    The ID of the client this role mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId String
    The ID of the client scope this role mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    realmId String
    The realm this role mapper exists within.
    roleId String
    The ID of the role to be added to this role mapper.

    Import

    Generic client role mappers can be imported using one of the following two formats:

    • When mapping a role to a client, use the format {{realmId}}/client/{{clientId}}/scope-mappings/{{roleClientId}}/{{roleId}}

    • When mapping a role to a client scope, use the format {{realmId}}/client-scope/{{clientScopeId}}/scope-mappings/{{roleClientId}}/{{roleId}}

    Example:

    bash

    $ pulumi import keycloak:index/genericClientRoleMapper:GenericClientRoleMapper client_role_mapper my-realm/client/23888550-5dcd-41f6-85ba-554233021e9c/scope-mappings/ce51f004-bdfb-4dd5-a963-c4487d2dec5b/ff3aa49f-bc07-4030-8783-41918c3614a3
    

    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.
    keycloak logo
    Keycloak v5.3.2 published on Friday, May 10, 2024 by Pulumi