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

keycloak.openid.ClientServiceAccountRealmRole

Explore with Pulumi AI

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

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

    Create ClientServiceAccountRealmRole Resource

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

    Constructor syntax

    new ClientServiceAccountRealmRole(name: string, args: ClientServiceAccountRealmRoleArgs, opts?: CustomResourceOptions);
    @overload
    def ClientServiceAccountRealmRole(resource_name: str,
                                      args: ClientServiceAccountRealmRoleArgs,
                                      opts: Optional[ResourceOptions] = None)
    
    @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)
    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.
    
    

    Parameters

    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.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var clientServiceAccountRealmRoleResource = new Keycloak.OpenId.ClientServiceAccountRealmRole("clientServiceAccountRealmRoleResource", new()
    {
        RealmId = "string",
        Role = "string",
        ServiceAccountUserId = "string",
    });
    
    example, err := openid.NewClientServiceAccountRealmRole(ctx, "clientServiceAccountRealmRoleResource", &openid.ClientServiceAccountRealmRoleArgs{
    	RealmId:              pulumi.String("string"),
    	Role:                 pulumi.String("string"),
    	ServiceAccountUserId: pulumi.String("string"),
    })
    
    var clientServiceAccountRealmRoleResource = new ClientServiceAccountRealmRole("clientServiceAccountRealmRoleResource", ClientServiceAccountRealmRoleArgs.builder()
        .realmId("string")
        .role("string")
        .serviceAccountUserId("string")
        .build());
    
    client_service_account_realm_role_resource = keycloak.openid.ClientServiceAccountRealmRole("clientServiceAccountRealmRoleResource",
        realm_id="string",
        role="string",
        service_account_user_id="string")
    
    const clientServiceAccountRealmRoleResource = new keycloak.openid.ClientServiceAccountRealmRole("clientServiceAccountRealmRoleResource", {
        realmId: "string",
        role: "string",
        serviceAccountUserId: "string",
    });
    
    type: keycloak:openid:ClientServiceAccountRealmRole
    properties:
        realmId: string
        role: string
        serviceAccountUserId: string
    

    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}}.

    Example:

    bash

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

    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