1. Packages
  2. Keycloak
  3. API Docs
  4. openid
  5. ClientServiceAccountRealmRole
Keycloak v5.3.0 published on Tuesday, Jan 9, 2024 by Pulumi

keycloak.openid.ClientServiceAccountRealmRole

Explore with Pulumi AI

keycloak logo
Keycloak v5.3.0 published on Tuesday, Jan 9, 2024 by Pulumi

    Allows for assigning realm roles to the service account of an openid client. You need to set service_accounts_enabled to true for the openid client that should be assigned the role.

    If you’d like to attach client roles to a service account, please use the keycloak.openid.ClientServiceAccountRole resource.

    Example Usage

    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 realmRole = new Keycloak.Role("realmRole", new()
        {
            RealmId = realm.Id,
        });
    
        var client = new Keycloak.OpenId.Client("client", new()
        {
            RealmId = realm.Id,
            ServiceAccountsEnabled = true,
        });
    
        var clientServiceAccountRole = new Keycloak.OpenId.ClientServiceAccountRealmRole("clientServiceAccountRole", new()
        {
            RealmId = realm.Id,
            ServiceAccountUserId = client.ServiceAccountUserId,
            Role = realmRole.Name,
        });
    
    });
    
    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
    		}
    		realmRole, err := keycloak.NewRole(ctx, "realmRole", &keycloak.RoleArgs{
    			RealmId: realm.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		client, err := openid.NewClient(ctx, "client", &openid.ClientArgs{
    			RealmId:                realm.ID(),
    			ServiceAccountsEnabled: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = openid.NewClientServiceAccountRealmRole(ctx, "clientServiceAccountRole", &openid.ClientServiceAccountRealmRoleArgs{
    			RealmId:              realm.ID(),
    			ServiceAccountUserId: client.ServiceAccountUserId,
    			Role:                 realmRole.Name,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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.Role;
    import com.pulumi.keycloak.RoleArgs;
    import com.pulumi.keycloak.openid.Client;
    import com.pulumi.keycloak.openid.ClientArgs;
    import com.pulumi.keycloak.openid.ClientServiceAccountRealmRole;
    import com.pulumi.keycloak.openid.ClientServiceAccountRealmRoleArgs;
    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 realmRole = new Role("realmRole", RoleArgs.builder()        
                .realmId(realm.id())
                .build());
    
            var client = new Client("client", ClientArgs.builder()        
                .realmId(realm.id())
                .serviceAccountsEnabled(true)
                .build());
    
            var clientServiceAccountRole = new ClientServiceAccountRealmRole("clientServiceAccountRole", ClientServiceAccountRealmRoleArgs.builder()        
                .realmId(realm.id())
                .serviceAccountUserId(client.serviceAccountUserId())
                .role(realmRole.name())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    realm_role = keycloak.Role("realmRole", realm_id=realm.id)
    client = keycloak.openid.Client("client",
        realm_id=realm.id,
        service_accounts_enabled=True)
    client_service_account_role = keycloak.openid.ClientServiceAccountRealmRole("clientServiceAccountRole",
        realm_id=realm.id,
        service_account_user_id=client.service_account_user_id,
        role=realm_role.name)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as keycloak from "@pulumi/keycloak";
    
    const realm = new keycloak.Realm("realm", {
        realm: "my-realm",
        enabled: true,
    });
    const realmRole = new keycloak.Role("realmRole", {realmId: realm.id});
    const client = new keycloak.openid.Client("client", {
        realmId: realm.id,
        serviceAccountsEnabled: true,
    });
    const clientServiceAccountRole = new keycloak.openid.ClientServiceAccountRealmRole("clientServiceAccountRole", {
        realmId: realm.id,
        serviceAccountUserId: client.serviceAccountUserId,
        role: realmRole.name,
    });
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      realmRole:
        type: keycloak:Role
        properties:
          realmId: ${realm.id}
      client:
        type: keycloak:openid:Client
        properties:
          realmId: ${realm.id}
          serviceAccountsEnabled: true
      clientServiceAccountRole:
        type: keycloak:openid:ClientServiceAccountRealmRole
        properties:
          realmId: ${realm.id}
          serviceAccountUserId: ${client.serviceAccountUserId}
          role: ${realmRole.name}
    

    Create ClientServiceAccountRealmRole Resource

    new ClientServiceAccountRealmRole(name: string, args: ClientServiceAccountRealmRoleArgs, opts?: CustomResourceOptions);
    @overload
    def ClientServiceAccountRealmRole(resource_name: str,
                                      opts: Optional[ResourceOptions] = None,
                                      realm_id: Optional[str] = None,
                                      role: Optional[str] = None,
                                      service_account_user_id: Optional[str] = None)
    @overload
    def ClientServiceAccountRealmRole(resource_name: str,
                                      args: ClientServiceAccountRealmRoleArgs,
                                      opts: Optional[ResourceOptions] = None)
    func NewClientServiceAccountRealmRole(ctx *Context, name string, args ClientServiceAccountRealmRoleArgs, opts ...ResourceOption) (*ClientServiceAccountRealmRole, error)
    public ClientServiceAccountRealmRole(string name, ClientServiceAccountRealmRoleArgs args, CustomResourceOptions? opts = null)
    public ClientServiceAccountRealmRole(String name, ClientServiceAccountRealmRoleArgs args)
    public ClientServiceAccountRealmRole(String name, ClientServiceAccountRealmRoleArgs args, CustomResourceOptions options)
    
    type: keycloak:openid:ClientServiceAccountRealmRole
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args ClientServiceAccountRealmRoleArgs
    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 ClientServiceAccountRealmRoleArgs
    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 ClientServiceAccountRealmRoleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ClientServiceAccountRealmRoleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ClientServiceAccountRealmRoleArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

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

    RealmId string
    The realm that the client and role belong to.
    Role string
    The name of the role that is assigned.
    ServiceAccountUserId string
    The id of the service account that is assigned the role (the service account of the client that "consumes" the role).
    RealmId string
    The realm that the client and role belong to.
    Role string
    The name of the role that is assigned.
    ServiceAccountUserId string
    The id of the service account that is assigned the role (the service account of the client that "consumes" the role).
    realmId String
    The realm that the client and role belong to.
    role String
    The name of the role that is assigned.
    serviceAccountUserId String
    The id of the service account that is assigned the role (the service account of the client that "consumes" the role).
    realmId string
    The realm that the client and role belong to.
    role string
    The name of the role that is assigned.
    serviceAccountUserId string
    The id of the service account that is assigned the role (the service account of the client that "consumes" the role).
    realm_id str
    The realm that the client and role belong to.
    role str
    The name of the role that is assigned.
    service_account_user_id str
    The id of the service account that is assigned the role (the service account of the client that "consumes" the role).
    realmId String
    The realm that the client and role belong to.
    role String
    The name of the role that is assigned.
    serviceAccountUserId String
    The id of the service account that is assigned the role (the service account of the client that "consumes" the role).

    Outputs

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

    Get an existing ClientServiceAccountRealmRole 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?: ClientServiceAccountRealmRoleState, opts?: CustomResourceOptions): ClientServiceAccountRealmRole
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            realm_id: Optional[str] = None,
            role: Optional[str] = None,
            service_account_user_id: Optional[str] = None) -> ClientServiceAccountRealmRole
    func GetClientServiceAccountRealmRole(ctx *Context, name string, id IDInput, state *ClientServiceAccountRealmRoleState, opts ...ResourceOption) (*ClientServiceAccountRealmRole, error)
    public static ClientServiceAccountRealmRole Get(string name, Input<string> id, ClientServiceAccountRealmRoleState? state, CustomResourceOptions? opts = null)
    public static ClientServiceAccountRealmRole get(String name, Output<String> id, ClientServiceAccountRealmRoleState 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:
    RealmId string
    The realm that the client and role belong to.
    Role string
    The name of the role that is assigned.
    ServiceAccountUserId string
    The id of the service account that is assigned the role (the service account of the client that "consumes" the role).
    RealmId string
    The realm that the client and role belong to.
    Role string
    The name of the role that is assigned.
    ServiceAccountUserId string
    The id of the service account that is assigned the role (the service account of the client that "consumes" the role).
    realmId String
    The realm that the client and role belong to.
    role String
    The name of the role that is assigned.
    serviceAccountUserId String
    The id of the service account that is assigned the role (the service account of the client that "consumes" the role).
    realmId string
    The realm that the client and role belong to.
    role string
    The name of the role that is assigned.
    serviceAccountUserId string
    The id of the service account that is assigned the role (the service account of the client that "consumes" the role).
    realm_id str
    The realm that the client and role belong to.
    role str
    The name of the role that is assigned.
    service_account_user_id str
    The id of the service account that is assigned the role (the service account of the client that "consumes" the role).
    realmId String
    The realm that the client and role belong to.
    role String
    The name of the role that is assigned.
    serviceAccountUserId String
    The id of the service account that is assigned the role (the service account of the client that "consumes" the role).

    Import

    This resource can be imported using the format {{realmId}}/{{serviceAccountUserId}}/{{roleId}}. Examplebash

     $ pulumi import keycloak:openid/clientServiceAccountRealmRole:ClientServiceAccountRealmRole client_service_account_role my-realm/489ba513-1ceb-49ba-ae0b-1ab1f5099ebf/c7230ab7-8e4e-4135-995d-e81b50696ad8
    

    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.0 published on Tuesday, Jan 9, 2024 by Pulumi