1. Packages
  2. HashiCorp Vault
  3. API Docs
  4. identity
  5. OidcRole
HashiCorp Vault v6.2.0 published on Friday, Jun 21, 2024 by Pulumi

vault.identity.OidcRole

Explore with Pulumi AI

vault logo
HashiCorp Vault v6.2.0 published on Friday, Jun 21, 2024 by Pulumi

    Example Usage

    You need to create a role with a named key. At creation time, the key can be created independently of the role. However, the key must exist before the role can be used to issue tokens. You must also configure the key with the role’s Client ID to allow the role to use the key.

    import * as pulumi from "@pulumi/pulumi";
    import * as vault from "@pulumi/vault";
    
    const config = new pulumi.Config();
    // Name of the OIDC Key
    const key = config.get("key") || "key";
    const role = new vault.identity.OidcRole("role", {
        name: "role",
        key: key,
    });
    const keyOidcKey = new vault.identity.OidcKey("key", {
        name: key,
        algorithm: "RS256",
        allowedClientIds: [role.clientId],
    });
    
    import pulumi
    import pulumi_vault as vault
    
    config = pulumi.Config()
    # Name of the OIDC Key
    key = config.get("key")
    if key is None:
        key = "key"
    role = vault.identity.OidcRole("role",
        name="role",
        key=key)
    key_oidc_key = vault.identity.OidcKey("key",
        name=key,
        algorithm="RS256",
        allowed_client_ids=[role.client_id])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-vault/sdk/v6/go/vault/identity"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		cfg := config.New(ctx, "")
    		// Name of the OIDC Key
    		key := "key"
    		if param := cfg.Get("key"); param != "" {
    			key = param
    		}
    		role, err := identity.NewOidcRole(ctx, "role", &identity.OidcRoleArgs{
    			Name: pulumi.String("role"),
    			Key:  pulumi.String(key),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = identity.NewOidcKey(ctx, "key", &identity.OidcKeyArgs{
    			Name:      pulumi.String(key),
    			Algorithm: pulumi.String("RS256"),
    			AllowedClientIds: pulumi.StringArray{
    				role.ClientId,
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Vault = Pulumi.Vault;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        // Name of the OIDC Key
        var key = config.Get("key") ?? "key";
        var role = new Vault.Identity.OidcRole("role", new()
        {
            Name = "role",
            Key = key,
        });
    
        var keyOidcKey = new Vault.Identity.OidcKey("key", new()
        {
            Name = key,
            Algorithm = "RS256",
            AllowedClientIds = new[]
            {
                role.ClientId,
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.vault.identity.OidcRole;
    import com.pulumi.vault.identity.OidcRoleArgs;
    import com.pulumi.vault.identity.OidcKey;
    import com.pulumi.vault.identity.OidcKeyArgs;
    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) {
            final var config = ctx.config();
            final var key = config.get("key").orElse("key");
            var role = new OidcRole("role", OidcRoleArgs.builder()
                .name("role")
                .key(key)
                .build());
    
            var keyOidcKey = new OidcKey("keyOidcKey", OidcKeyArgs.builder()
                .name(key)
                .algorithm("RS256")
                .allowedClientIds(role.clientId())
                .build());
    
        }
    }
    
    configuration:
      key:
        type: string
        default: key
    resources:
      keyOidcKey:
        type: vault:identity:OidcKey
        name: key
        properties:
          name: ${key}
          algorithm: RS256
          allowedClientIds:
            - ${role.clientId}
      role:
        type: vault:identity:OidcRole
        properties:
          name: role
          key: ${key}
    

    If you want to create the key first before creating the role, you can use a separate resource to configure the allowed Client ID on the key.

    import * as pulumi from "@pulumi/pulumi";
    import * as vault from "@pulumi/vault";
    
    const key = new vault.identity.OidcKey("key", {
        name: "key",
        algorithm: "RS256",
    });
    const role = new vault.identity.OidcRole("role", {
        name: "role",
        key: key.name,
    });
    const roleOidcKeyAllowedClientID = new vault.identity.OidcKeyAllowedClientID("role", {
        keyName: key.name,
        allowedClientId: role.clientId,
    });
    
    import pulumi
    import pulumi_vault as vault
    
    key = vault.identity.OidcKey("key",
        name="key",
        algorithm="RS256")
    role = vault.identity.OidcRole("role",
        name="role",
        key=key.name)
    role_oidc_key_allowed_client_id = vault.identity.OidcKeyAllowedClientID("role",
        key_name=key.name,
        allowed_client_id=role.client_id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-vault/sdk/v6/go/vault/identity"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		key, err := identity.NewOidcKey(ctx, "key", &identity.OidcKeyArgs{
    			Name:      pulumi.String("key"),
    			Algorithm: pulumi.String("RS256"),
    		})
    		if err != nil {
    			return err
    		}
    		role, err := identity.NewOidcRole(ctx, "role", &identity.OidcRoleArgs{
    			Name: pulumi.String("role"),
    			Key:  key.Name,
    		})
    		if err != nil {
    			return err
    		}
    		_, err = identity.NewOidcKeyAllowedClientID(ctx, "role", &identity.OidcKeyAllowedClientIDArgs{
    			KeyName:         key.Name,
    			AllowedClientId: role.ClientId,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Vault = Pulumi.Vault;
    
    return await Deployment.RunAsync(() => 
    {
        var key = new Vault.Identity.OidcKey("key", new()
        {
            Name = "key",
            Algorithm = "RS256",
        });
    
        var role = new Vault.Identity.OidcRole("role", new()
        {
            Name = "role",
            Key = key.Name,
        });
    
        var roleOidcKeyAllowedClientID = new Vault.Identity.OidcKeyAllowedClientID("role", new()
        {
            KeyName = key.Name,
            AllowedClientId = role.ClientId,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.vault.identity.OidcKey;
    import com.pulumi.vault.identity.OidcKeyArgs;
    import com.pulumi.vault.identity.OidcRole;
    import com.pulumi.vault.identity.OidcRoleArgs;
    import com.pulumi.vault.identity.OidcKeyAllowedClientID;
    import com.pulumi.vault.identity.OidcKeyAllowedClientIDArgs;
    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 key = new OidcKey("key", OidcKeyArgs.builder()
                .name("key")
                .algorithm("RS256")
                .build());
    
            var role = new OidcRole("role", OidcRoleArgs.builder()
                .name("role")
                .key(key.name())
                .build());
    
            var roleOidcKeyAllowedClientID = new OidcKeyAllowedClientID("roleOidcKeyAllowedClientID", OidcKeyAllowedClientIDArgs.builder()
                .keyName(key.name())
                .allowedClientId(role.clientId())
                .build());
    
        }
    }
    
    resources:
      key:
        type: vault:identity:OidcKey
        properties:
          name: key
          algorithm: RS256
      role:
        type: vault:identity:OidcRole
        properties:
          name: role
          key: ${key.name}
      roleOidcKeyAllowedClientID:
        type: vault:identity:OidcKeyAllowedClientID
        name: role
        properties:
          keyName: ${key.name}
          allowedClientId: ${role.clientId}
    

    Create OidcRole Resource

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

    Constructor syntax

    new OidcRole(name: string, args: OidcRoleArgs, opts?: CustomResourceOptions);
    @overload
    def OidcRole(resource_name: str,
                 args: OidcRoleArgs,
                 opts: Optional[ResourceOptions] = None)
    
    @overload
    def OidcRole(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 key: Optional[str] = None,
                 client_id: Optional[str] = None,
                 name: Optional[str] = None,
                 namespace: Optional[str] = None,
                 template: Optional[str] = None,
                 ttl: Optional[int] = None)
    func NewOidcRole(ctx *Context, name string, args OidcRoleArgs, opts ...ResourceOption) (*OidcRole, error)
    public OidcRole(string name, OidcRoleArgs args, CustomResourceOptions? opts = null)
    public OidcRole(String name, OidcRoleArgs args)
    public OidcRole(String name, OidcRoleArgs args, CustomResourceOptions options)
    
    type: vault:identity:OidcRole
    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 OidcRoleArgs
    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 OidcRoleArgs
    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 OidcRoleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args OidcRoleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args OidcRoleArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

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

    var oidcRoleResource = new Vault.Identity.OidcRole("oidcRoleResource", new()
    {
        Key = "string",
        ClientId = "string",
        Name = "string",
        Namespace = "string",
        Template = "string",
        Ttl = 0,
    });
    
    example, err := identity.NewOidcRole(ctx, "oidcRoleResource", &identity.OidcRoleArgs{
    	Key:       pulumi.String("string"),
    	ClientId:  pulumi.String("string"),
    	Name:      pulumi.String("string"),
    	Namespace: pulumi.String("string"),
    	Template:  pulumi.String("string"),
    	Ttl:       pulumi.Int(0),
    })
    
    var oidcRoleResource = new OidcRole("oidcRoleResource", OidcRoleArgs.builder()
        .key("string")
        .clientId("string")
        .name("string")
        .namespace("string")
        .template("string")
        .ttl(0)
        .build());
    
    oidc_role_resource = vault.identity.OidcRole("oidcRoleResource",
        key="string",
        client_id="string",
        name="string",
        namespace="string",
        template="string",
        ttl=0)
    
    const oidcRoleResource = new vault.identity.OidcRole("oidcRoleResource", {
        key: "string",
        clientId: "string",
        name: "string",
        namespace: "string",
        template: "string",
        ttl: 0,
    });
    
    type: vault:identity:OidcRole
    properties:
        clientId: string
        key: string
        name: string
        namespace: string
        template: string
        ttl: 0
    

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

    Key string
    A configured named key, the key must already exist before tokens can be issued.
    ClientId string
    The value that will be included in the aud field of all the OIDC identity tokens issued by this role
    Name string
    Name of the OIDC Role to create.
    Namespace string
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    Template string
    The template string to use for generating tokens. This may be in string-ified JSON or base64 format. See the documentation for the template format.
    Ttl int
    TTL of the tokens generated against the role in number of seconds.
    Key string
    A configured named key, the key must already exist before tokens can be issued.
    ClientId string
    The value that will be included in the aud field of all the OIDC identity tokens issued by this role
    Name string
    Name of the OIDC Role to create.
    Namespace string
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    Template string
    The template string to use for generating tokens. This may be in string-ified JSON or base64 format. See the documentation for the template format.
    Ttl int
    TTL of the tokens generated against the role in number of seconds.
    key String
    A configured named key, the key must already exist before tokens can be issued.
    clientId String
    The value that will be included in the aud field of all the OIDC identity tokens issued by this role
    name String
    Name of the OIDC Role to create.
    namespace String
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    template String
    The template string to use for generating tokens. This may be in string-ified JSON or base64 format. See the documentation for the template format.
    ttl Integer
    TTL of the tokens generated against the role in number of seconds.
    key string
    A configured named key, the key must already exist before tokens can be issued.
    clientId string
    The value that will be included in the aud field of all the OIDC identity tokens issued by this role
    name string
    Name of the OIDC Role to create.
    namespace string
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    template string
    The template string to use for generating tokens. This may be in string-ified JSON or base64 format. See the documentation for the template format.
    ttl number
    TTL of the tokens generated against the role in number of seconds.
    key str
    A configured named key, the key must already exist before tokens can be issued.
    client_id str
    The value that will be included in the aud field of all the OIDC identity tokens issued by this role
    name str
    Name of the OIDC Role to create.
    namespace str
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    template str
    The template string to use for generating tokens. This may be in string-ified JSON or base64 format. See the documentation for the template format.
    ttl int
    TTL of the tokens generated against the role in number of seconds.
    key String
    A configured named key, the key must already exist before tokens can be issued.
    clientId String
    The value that will be included in the aud field of all the OIDC identity tokens issued by this role
    name String
    Name of the OIDC Role to create.
    namespace String
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    template String
    The template string to use for generating tokens. This may be in string-ified JSON or base64 format. See the documentation for the template format.
    ttl Number
    TTL of the tokens generated against the role in number of seconds.

    Outputs

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

    Get an existing OidcRole 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?: OidcRoleState, opts?: CustomResourceOptions): OidcRole
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            client_id: Optional[str] = None,
            key: Optional[str] = None,
            name: Optional[str] = None,
            namespace: Optional[str] = None,
            template: Optional[str] = None,
            ttl: Optional[int] = None) -> OidcRole
    func GetOidcRole(ctx *Context, name string, id IDInput, state *OidcRoleState, opts ...ResourceOption) (*OidcRole, error)
    public static OidcRole Get(string name, Input<string> id, OidcRoleState? state, CustomResourceOptions? opts = null)
    public static OidcRole get(String name, Output<String> id, OidcRoleState 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 value that will be included in the aud field of all the OIDC identity tokens issued by this role
    Key string
    A configured named key, the key must already exist before tokens can be issued.
    Name string
    Name of the OIDC Role to create.
    Namespace string
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    Template string
    The template string to use for generating tokens. This may be in string-ified JSON or base64 format. See the documentation for the template format.
    Ttl int
    TTL of the tokens generated against the role in number of seconds.
    ClientId string
    The value that will be included in the aud field of all the OIDC identity tokens issued by this role
    Key string
    A configured named key, the key must already exist before tokens can be issued.
    Name string
    Name of the OIDC Role to create.
    Namespace string
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    Template string
    The template string to use for generating tokens. This may be in string-ified JSON or base64 format. See the documentation for the template format.
    Ttl int
    TTL of the tokens generated against the role in number of seconds.
    clientId String
    The value that will be included in the aud field of all the OIDC identity tokens issued by this role
    key String
    A configured named key, the key must already exist before tokens can be issued.
    name String
    Name of the OIDC Role to create.
    namespace String
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    template String
    The template string to use for generating tokens. This may be in string-ified JSON or base64 format. See the documentation for the template format.
    ttl Integer
    TTL of the tokens generated against the role in number of seconds.
    clientId string
    The value that will be included in the aud field of all the OIDC identity tokens issued by this role
    key string
    A configured named key, the key must already exist before tokens can be issued.
    name string
    Name of the OIDC Role to create.
    namespace string
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    template string
    The template string to use for generating tokens. This may be in string-ified JSON or base64 format. See the documentation for the template format.
    ttl number
    TTL of the tokens generated against the role in number of seconds.
    client_id str
    The value that will be included in the aud field of all the OIDC identity tokens issued by this role
    key str
    A configured named key, the key must already exist before tokens can be issued.
    name str
    Name of the OIDC Role to create.
    namespace str
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    template str
    The template string to use for generating tokens. This may be in string-ified JSON or base64 format. See the documentation for the template format.
    ttl int
    TTL of the tokens generated against the role in number of seconds.
    clientId String
    The value that will be included in the aud field of all the OIDC identity tokens issued by this role
    key String
    A configured named key, the key must already exist before tokens can be issued.
    name String
    Name of the OIDC Role to create.
    namespace String
    The namespace to provision the resource in. The value should not contain leading or trailing forward slashes. The namespace is always relative to the provider's configured namespace. Available only for Vault Enterprise.
    template String
    The template string to use for generating tokens. This may be in string-ified JSON or base64 format. See the documentation for the template format.
    ttl Number
    TTL of the tokens generated against the role in number of seconds.

    Import

    The key can be imported with the role name, for example:

    $ pulumi import vault:identity/oidcRole:OidcRole role role
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Vault pulumi/pulumi-vault
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the vault Terraform Provider.
    vault logo
    HashiCorp Vault v6.2.0 published on Friday, Jun 21, 2024 by Pulumi