1. Packages
  2. Keycloak Provider
  3. API Docs
  4. RealmOptionalClientScopes
Keycloak v6.4.0 published on Wednesday, Apr 16, 2025 by Pulumi

keycloak.RealmOptionalClientScopes

Explore with Pulumi AI

keycloak logo
Keycloak v6.4.0 published on Wednesday, Apr 16, 2025 by Pulumi

    Allows you to manage the set of optional client scopes for a Keycloak realm, which are used when new clients are created.

    Note that this resource attempts to be an authoritative source over the optional client scopes for a Keycloak realm, so any Keycloak defaults and manual adjustments will be overwritten.

    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 clientScope = new keycloak.openid.ClientScope("client_scope", {
        realmId: realm.id,
        name: "test-client-scope",
    });
    const optionalScopes = new keycloak.RealmOptionalClientScopes("optional_scopes", {
        realmId: realm.id,
        optionalScopes: [
            "address",
            "phone",
            "offline_access",
            "microprofile-jwt",
            clientScope.name,
        ],
    });
    
    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="test-client-scope")
    optional_scopes = keycloak.RealmOptionalClientScopes("optional_scopes",
        realm_id=realm.id,
        optional_scopes=[
            "address",
            "phone",
            "offline_access",
            "microprofile-jwt",
            client_scope.name,
        ])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-keycloak/sdk/v6/go/keycloak"
    	"github.com/pulumi/pulumi-keycloak/sdk/v6/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("test-client-scope"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewRealmOptionalClientScopes(ctx, "optional_scopes", &keycloak.RealmOptionalClientScopesArgs{
    			RealmId: realm.ID(),
    			OptionalScopes: pulumi.StringArray{
    				pulumi.String("address"),
    				pulumi.String("phone"),
    				pulumi.String("offline_access"),
    				pulumi.String("microprofile-jwt"),
    				clientScope.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 clientScope = new Keycloak.OpenId.ClientScope("client_scope", new()
        {
            RealmId = realm.Id,
            Name = "test-client-scope",
        });
    
        var optionalScopes = new Keycloak.RealmOptionalClientScopes("optional_scopes", new()
        {
            RealmId = realm.Id,
            OptionalScopes = new[]
            {
                "address",
                "phone",
                "offline_access",
                "microprofile-jwt",
                clientScope.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.openid.ClientScope;
    import com.pulumi.keycloak.openid.ClientScopeArgs;
    import com.pulumi.keycloak.RealmOptionalClientScopes;
    import com.pulumi.keycloak.RealmOptionalClientScopesArgs;
    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("test-client-scope")
                .build());
    
            var optionalScopes = new RealmOptionalClientScopes("optionalScopes", RealmOptionalClientScopesArgs.builder()
                .realmId(realm.id())
                .optionalScopes(            
                    "address",
                    "phone",
                    "offline_access",
                    "microprofile-jwt",
                    clientScope.name())
                .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: test-client-scope
      optionalScopes:
        type: keycloak:RealmOptionalClientScopes
        name: optional_scopes
        properties:
          realmId: ${realm.id}
          optionalScopes:
            - address
            - phone
            - offline_access
            - microprofile-jwt
            - ${clientScope.name}
    

    Create RealmOptionalClientScopes Resource

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

    Constructor syntax

    new RealmOptionalClientScopes(name: string, args: RealmOptionalClientScopesArgs, opts?: CustomResourceOptions);
    @overload
    def RealmOptionalClientScopes(resource_name: str,
                                  args: RealmOptionalClientScopesArgs,
                                  opts: Optional[ResourceOptions] = None)
    
    @overload
    def RealmOptionalClientScopes(resource_name: str,
                                  opts: Optional[ResourceOptions] = None,
                                  optional_scopes: Optional[Sequence[str]] = None,
                                  realm_id: Optional[str] = None)
    func NewRealmOptionalClientScopes(ctx *Context, name string, args RealmOptionalClientScopesArgs, opts ...ResourceOption) (*RealmOptionalClientScopes, error)
    public RealmOptionalClientScopes(string name, RealmOptionalClientScopesArgs args, CustomResourceOptions? opts = null)
    public RealmOptionalClientScopes(String name, RealmOptionalClientScopesArgs args)
    public RealmOptionalClientScopes(String name, RealmOptionalClientScopesArgs args, CustomResourceOptions options)
    
    type: keycloak:RealmOptionalClientScopes
    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 RealmOptionalClientScopesArgs
    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 RealmOptionalClientScopesArgs
    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 RealmOptionalClientScopesArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RealmOptionalClientScopesArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RealmOptionalClientScopesArgs
    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 realmOptionalClientScopesResource = new Keycloak.RealmOptionalClientScopes("realmOptionalClientScopesResource", new()
    {
        OptionalScopes = new[]
        {
            "string",
        },
        RealmId = "string",
    });
    
    example, err := keycloak.NewRealmOptionalClientScopes(ctx, "realmOptionalClientScopesResource", &keycloak.RealmOptionalClientScopesArgs{
    	OptionalScopes: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	RealmId: pulumi.String("string"),
    })
    
    var realmOptionalClientScopesResource = new RealmOptionalClientScopes("realmOptionalClientScopesResource", RealmOptionalClientScopesArgs.builder()
        .optionalScopes("string")
        .realmId("string")
        .build());
    
    realm_optional_client_scopes_resource = keycloak.RealmOptionalClientScopes("realmOptionalClientScopesResource",
        optional_scopes=["string"],
        realm_id="string")
    
    const realmOptionalClientScopesResource = new keycloak.RealmOptionalClientScopes("realmOptionalClientScopesResource", {
        optionalScopes: ["string"],
        realmId: "string",
    });
    
    type: keycloak:RealmOptionalClientScopes
    properties:
        optionalScopes:
            - string
        realmId: string
    

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

    OptionalScopes List<string>
    An array of optional client scope names that should be used when creating new Keycloak clients.
    RealmId string
    The realm this client and scopes exists in.
    OptionalScopes []string
    An array of optional client scope names that should be used when creating new Keycloak clients.
    RealmId string
    The realm this client and scopes exists in.
    optionalScopes List<String>
    An array of optional client scope names that should be used when creating new Keycloak clients.
    realmId String
    The realm this client and scopes exists in.
    optionalScopes string[]
    An array of optional client scope names that should be used when creating new Keycloak clients.
    realmId string
    The realm this client and scopes exists in.
    optional_scopes Sequence[str]
    An array of optional client scope names that should be used when creating new Keycloak clients.
    realm_id str
    The realm this client and scopes exists in.
    optionalScopes List<String>
    An array of optional client scope names that should be used when creating new Keycloak clients.
    realmId String
    The realm this client and scopes exists in.

    Outputs

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

    Get an existing RealmOptionalClientScopes 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?: RealmOptionalClientScopesState, opts?: CustomResourceOptions): RealmOptionalClientScopes
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            optional_scopes: Optional[Sequence[str]] = None,
            realm_id: Optional[str] = None) -> RealmOptionalClientScopes
    func GetRealmOptionalClientScopes(ctx *Context, name string, id IDInput, state *RealmOptionalClientScopesState, opts ...ResourceOption) (*RealmOptionalClientScopes, error)
    public static RealmOptionalClientScopes Get(string name, Input<string> id, RealmOptionalClientScopesState? state, CustomResourceOptions? opts = null)
    public static RealmOptionalClientScopes get(String name, Output<String> id, RealmOptionalClientScopesState state, CustomResourceOptions options)
    resources:  _:    type: keycloak:RealmOptionalClientScopes    get:      id: ${id}
    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:
    OptionalScopes List<string>
    An array of optional client scope names that should be used when creating new Keycloak clients.
    RealmId string
    The realm this client and scopes exists in.
    OptionalScopes []string
    An array of optional client scope names that should be used when creating new Keycloak clients.
    RealmId string
    The realm this client and scopes exists in.
    optionalScopes List<String>
    An array of optional client scope names that should be used when creating new Keycloak clients.
    realmId String
    The realm this client and scopes exists in.
    optionalScopes string[]
    An array of optional client scope names that should be used when creating new Keycloak clients.
    realmId string
    The realm this client and scopes exists in.
    optional_scopes Sequence[str]
    An array of optional client scope names that should be used when creating new Keycloak clients.
    realm_id str
    The realm this client and scopes exists in.
    optionalScopes List<String>
    An array of optional client scope names that should be used when creating new Keycloak clients.
    realmId String
    The realm this client and scopes exists in.

    Import

    This resource does not support import. Instead of importing, feel free to create this resource

    as if it did not already exist on the server.

    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 v6.4.0 published on Wednesday, Apr 16, 2025 by Pulumi