1. Packages
  2. Keycloak
  3. API Docs
  4. getRole
Keycloak v5.3.1 published on Monday, Mar 11, 2024 by Pulumi

keycloak.getRole

Explore with Pulumi AI

keycloak logo
Keycloak v5.3.1 published on Monday, Mar 11, 2024 by Pulumi

    # keycloak.Role data source

    This data source can be used to fetch properties of a Keycloak role for usage with other resources, such as keycloak.GroupRoles.

    Example Usage

    Coming soon!```
    </pulumi-choosable>
    </div>
    <div>
    <pulumi-choosable type="language" values="python">
    

    Coming soon!```

    Coming soon!```
    </pulumi-choosable>
    </div>
    <div>
    <pulumi-choosable type="language" values="csharp">
    

    Coming soon!```

    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.KeycloakFunctions;
    import com.pulumi.keycloak.inputs.GetRoleArgs;
    import com.pulumi.keycloak.Group;
    import com.pulumi.keycloak.GroupArgs;
    import com.pulumi.keycloak.GroupRoles;
    import com.pulumi.keycloak.GroupRolesArgs;
    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()        
                .enabled(true)
                .realm("my-realm")
                .build());
    
            final var offlineAccess = KeycloakFunctions.getRole(GetRoleArgs.builder()
                .name("offline_access")
                .realmId(realm.id())
                .build());
    
            var group = new Group("group", GroupArgs.builder()        
                .realmId(realm.id())
                .build());
    
            var groupRoles = new GroupRoles("groupRoles", GroupRolesArgs.builder()        
                .groupId(group.id())
                .realmId(realm.id())
                .roles(offlineAccess.applyValue(getRoleResult -> getRoleResult).applyValue(offlineAccess -> offlineAccess.applyValue(getRoleResult -> getRoleResult.id())))
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          enabled: true
          realm: my-realm
      group:
        type: keycloak:Group
        properties:
          realmId: ${realm.id}
      groupRoles:
        type: keycloak:GroupRoles
        properties:
          groupId: ${group.id}
          realmId: ${realm.id}
          roles:
            - ${offlineAccess.id}
    variables:
      offlineAccess:
        fn::invoke:
          Function: keycloak:getRole
          Arguments:
            name: offline_access
            realmId: ${realm.id}
    

    Argument Reference

    The following arguments are supported:

    • realm_id - (Required) The realm this role exists within.
    • client_id - (Optional) When specified, this role is assumed to be a client role belonging to the client with the provided ID
    • name - (Required) The name of the role

    Attributes Reference

    In addition to the arguments listed above, the following computed attributes are exported:

    • id - The unique ID of the role, which can be used as an argument to other resources supported by this provider.
    • description - The description of the role.

    Using getRole

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getRole(args: GetRoleArgs, opts?: InvokeOptions): Promise<GetRoleResult>
    function getRoleOutput(args: GetRoleOutputArgs, opts?: InvokeOptions): Output<GetRoleResult>
    def get_role(client_id: Optional[str] = None,
                 name: Optional[str] = None,
                 realm_id: Optional[str] = None,
                 opts: Optional[InvokeOptions] = None) -> GetRoleResult
    def get_role_output(client_id: Optional[pulumi.Input[str]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 realm_id: Optional[pulumi.Input[str]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetRoleResult]
    func LookupRole(ctx *Context, args *LookupRoleArgs, opts ...InvokeOption) (*LookupRoleResult, error)
    func LookupRoleOutput(ctx *Context, args *LookupRoleOutputArgs, opts ...InvokeOption) LookupRoleResultOutput

    > Note: This function is named LookupRole in the Go SDK.

    public static class GetRole 
    {
        public static Task<GetRoleResult> InvokeAsync(GetRoleArgs args, InvokeOptions? opts = null)
        public static Output<GetRoleResult> Invoke(GetRoleInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetRoleResult> getRole(GetRoleArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: keycloak:index/getRole:getRole
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    RealmId string
    ClientId string
    Name string
    RealmId string
    ClientId string
    name String
    realmId String
    clientId String
    name string
    realmId string
    clientId string
    name String
    realmId String
    clientId String

    getRole Result

    The following output properties are available:

    Attributes Dictionary<string, object>
    CompositeRoles List<string>
    Description string
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    RealmId string
    ClientId string
    Attributes map[string]interface{}
    CompositeRoles []string
    Description string
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    RealmId string
    ClientId string
    attributes Map<String,Object>
    compositeRoles List<String>
    description String
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    realmId String
    clientId String
    attributes {[key: string]: any}
    compositeRoles string[]
    description string
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    realmId string
    clientId string
    attributes Mapping[str, Any]
    composite_roles Sequence[str]
    description str
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    realm_id str
    client_id str
    attributes Map<Any>
    compositeRoles List<String>
    description String
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    realmId String
    clientId String

    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.1 published on Monday, Mar 11, 2024 by Pulumi