1. Packages
  2. Databricks Provider
  3. API Docs
  4. Secret
Databricks v1.65.0 published on Wednesday, Apr 9, 2025 by Pulumi

databricks.Secret

Explore with Pulumi AI

With this resource you can insert a secret under the provided scope with the given name. If a secret already exists with the same name, this command overwrites the existing secret’s value. The server encrypts the secret using the secret scope’s encryption settings before storing it. You must have WRITE or MANAGE permission on the secret scope. The secret key must consist of alphanumeric characters, dashes, underscores, and periods, and cannot exceed 128 characters. The maximum allowed secret value size is 128 KB. The maximum number of secrets in a given scope is 1000. You can read a secret value only from within a command on a cluster (for example, through a notebook); there is no API to read a secret value outside of a cluster. The permission applied is based on who is invoking the command and you must have at least READ permission. Please consult Secrets User Guide for more details.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as databricks from "@pulumi/databricks";

const app = new databricks.SecretScope("app", {name: "application-secret-scope"});
const publishingApi = new databricks.Secret("publishing_api", {
    key: "publishing_api",
    stringValue: example.value,
    scope: app.id,
});
const _this = new databricks.Cluster("this", {sparkConf: {
    "fs.azure.account.oauth2.client.secret": publishingApi.configReference,
}});
Copy
import pulumi
import pulumi_databricks as databricks

app = databricks.SecretScope("app", name="application-secret-scope")
publishing_api = databricks.Secret("publishing_api",
    key="publishing_api",
    string_value=example["value"],
    scope=app.id)
this = databricks.Cluster("this", spark_conf={
    "fs.azure.account.oauth2.client.secret": publishing_api.config_reference,
})
Copy
package main

import (
	"github.com/pulumi/pulumi-databricks/sdk/go/databricks"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		app, err := databricks.NewSecretScope(ctx, "app", &databricks.SecretScopeArgs{
			Name: pulumi.String("application-secret-scope"),
		})
		if err != nil {
			return err
		}
		publishingApi, err := databricks.NewSecret(ctx, "publishing_api", &databricks.SecretArgs{
			Key:         pulumi.String("publishing_api"),
			StringValue: pulumi.Any(example.Value),
			Scope:       app.ID(),
		})
		if err != nil {
			return err
		}
		_, err = databricks.NewCluster(ctx, "this", &databricks.ClusterArgs{
			SparkConf: pulumi.StringMap{
				"fs.azure.account.oauth2.client.secret": publishingApi.ConfigReference,
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Databricks = Pulumi.Databricks;

return await Deployment.RunAsync(() => 
{
    var app = new Databricks.SecretScope("app", new()
    {
        Name = "application-secret-scope",
    });

    var publishingApi = new Databricks.Secret("publishing_api", new()
    {
        Key = "publishing_api",
        StringValue = example.Value,
        Scope = app.Id,
    });

    var @this = new Databricks.Cluster("this", new()
    {
        SparkConf = 
        {
            { "fs.azure.account.oauth2.client.secret", publishingApi.ConfigReference },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.databricks.SecretScope;
import com.pulumi.databricks.SecretScopeArgs;
import com.pulumi.databricks.Secret;
import com.pulumi.databricks.SecretArgs;
import com.pulumi.databricks.Cluster;
import com.pulumi.databricks.ClusterArgs;
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 app = new SecretScope("app", SecretScopeArgs.builder()
            .name("application-secret-scope")
            .build());

        var publishingApi = new Secret("publishingApi", SecretArgs.builder()
            .key("publishing_api")
            .stringValue(example.value())
            .scope(app.id())
            .build());

        var this_ = new Cluster("this", ClusterArgs.builder()
            .sparkConf(Map.of("fs.azure.account.oauth2.client.secret", publishingApi.configReference()))
            .build());

    }
}
Copy
resources:
  app:
    type: databricks:SecretScope
    properties:
      name: application-secret-scope
  publishingApi:
    type: databricks:Secret
    name: publishing_api
    properties:
      key: publishing_api
      stringValue: ${example.value}
      scope: ${app.id}
  this:
    type: databricks:Cluster
    properties:
      sparkConf:
        fs.azure.account.oauth2.client.secret: ${publishingApi.configReference}
Copy

The following resources are often used in the same context:

Create Secret Resource

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

Constructor syntax

new Secret(name: string, args: SecretArgs, opts?: CustomResourceOptions);
@overload
def Secret(resource_name: str,
           args: SecretArgs,
           opts: Optional[ResourceOptions] = None)

@overload
def Secret(resource_name: str,
           opts: Optional[ResourceOptions] = None,
           key: Optional[str] = None,
           scope: Optional[str] = None,
           string_value: Optional[str] = None)
func NewSecret(ctx *Context, name string, args SecretArgs, opts ...ResourceOption) (*Secret, error)
public Secret(string name, SecretArgs args, CustomResourceOptions? opts = null)
public Secret(String name, SecretArgs args)
public Secret(String name, SecretArgs args, CustomResourceOptions options)
type: databricks:Secret
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. SecretArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. SecretArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. SecretArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. SecretArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. SecretArgs
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 secretResource = new Databricks.Secret("secretResource", new()
{
    Key = "string",
    Scope = "string",
    StringValue = "string",
});
Copy
example, err := databricks.NewSecret(ctx, "secretResource", &databricks.SecretArgs{
	Key:         pulumi.String("string"),
	Scope:       pulumi.String("string"),
	StringValue: pulumi.String("string"),
})
Copy
var secretResource = new Secret("secretResource", SecretArgs.builder()
    .key("string")
    .scope("string")
    .stringValue("string")
    .build());
Copy
secret_resource = databricks.Secret("secretResource",
    key="string",
    scope="string",
    string_value="string")
Copy
const secretResource = new databricks.Secret("secretResource", {
    key: "string",
    scope: "string",
    stringValue: "string",
});
Copy
type: databricks:Secret
properties:
    key: string
    scope: string
    stringValue: string
Copy

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

Key
This property is required.
Changes to this property will trigger replacement.
string
(String) key within secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
Scope
This property is required.
Changes to this property will trigger replacement.
string
(String) name of databricks secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
StringValue
This property is required.
Changes to this property will trigger replacement.
string
(String) super secret sensitive value.
Key
This property is required.
Changes to this property will trigger replacement.
string
(String) key within secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
Scope
This property is required.
Changes to this property will trigger replacement.
string
(String) name of databricks secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
StringValue
This property is required.
Changes to this property will trigger replacement.
string
(String) super secret sensitive value.
key
This property is required.
Changes to this property will trigger replacement.
String
(String) key within secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
scope
This property is required.
Changes to this property will trigger replacement.
String
(String) name of databricks secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
stringValue
This property is required.
Changes to this property will trigger replacement.
String
(String) super secret sensitive value.
key
This property is required.
Changes to this property will trigger replacement.
string
(String) key within secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
scope
This property is required.
Changes to this property will trigger replacement.
string
(String) name of databricks secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
stringValue
This property is required.
Changes to this property will trigger replacement.
string
(String) super secret sensitive value.
key
This property is required.
Changes to this property will trigger replacement.
str
(String) key within secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
scope
This property is required.
Changes to this property will trigger replacement.
str
(String) name of databricks secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
string_value
This property is required.
Changes to this property will trigger replacement.
str
(String) super secret sensitive value.
key
This property is required.
Changes to this property will trigger replacement.
String
(String) key within secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
scope
This property is required.
Changes to this property will trigger replacement.
String
(String) name of databricks secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
stringValue
This property is required.
Changes to this property will trigger replacement.
String
(String) super secret sensitive value.

Outputs

All input properties are implicitly available as output properties. Additionally, the Secret resource produces the following output properties:

ConfigReference string
(String) value to use as a secret reference in Spark configuration and environment variables: {{secrets/scope/key}}.
Id string
The provider-assigned unique ID for this managed resource.
LastUpdatedTimestamp int
(Integer) time secret was updated
ConfigReference string
(String) value to use as a secret reference in Spark configuration and environment variables: {{secrets/scope/key}}.
Id string
The provider-assigned unique ID for this managed resource.
LastUpdatedTimestamp int
(Integer) time secret was updated
configReference String
(String) value to use as a secret reference in Spark configuration and environment variables: {{secrets/scope/key}}.
id String
The provider-assigned unique ID for this managed resource.
lastUpdatedTimestamp Integer
(Integer) time secret was updated
configReference string
(String) value to use as a secret reference in Spark configuration and environment variables: {{secrets/scope/key}}.
id string
The provider-assigned unique ID for this managed resource.
lastUpdatedTimestamp number
(Integer) time secret was updated
config_reference str
(String) value to use as a secret reference in Spark configuration and environment variables: {{secrets/scope/key}}.
id str
The provider-assigned unique ID for this managed resource.
last_updated_timestamp int
(Integer) time secret was updated
configReference String
(String) value to use as a secret reference in Spark configuration and environment variables: {{secrets/scope/key}}.
id String
The provider-assigned unique ID for this managed resource.
lastUpdatedTimestamp Number
(Integer) time secret was updated

Look up Existing Secret Resource

Get an existing Secret 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?: SecretState, opts?: CustomResourceOptions): Secret
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        config_reference: Optional[str] = None,
        key: Optional[str] = None,
        last_updated_timestamp: Optional[int] = None,
        scope: Optional[str] = None,
        string_value: Optional[str] = None) -> Secret
func GetSecret(ctx *Context, name string, id IDInput, state *SecretState, opts ...ResourceOption) (*Secret, error)
public static Secret Get(string name, Input<string> id, SecretState? state, CustomResourceOptions? opts = null)
public static Secret get(String name, Output<String> id, SecretState state, CustomResourceOptions options)
resources:  _:    type: databricks:Secret    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
ConfigReference string
(String) value to use as a secret reference in Spark configuration and environment variables: {{secrets/scope/key}}.
Key Changes to this property will trigger replacement. string
(String) key within secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
LastUpdatedTimestamp int
(Integer) time secret was updated
Scope Changes to this property will trigger replacement. string
(String) name of databricks secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
StringValue Changes to this property will trigger replacement. string
(String) super secret sensitive value.
ConfigReference string
(String) value to use as a secret reference in Spark configuration and environment variables: {{secrets/scope/key}}.
Key Changes to this property will trigger replacement. string
(String) key within secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
LastUpdatedTimestamp int
(Integer) time secret was updated
Scope Changes to this property will trigger replacement. string
(String) name of databricks secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
StringValue Changes to this property will trigger replacement. string
(String) super secret sensitive value.
configReference String
(String) value to use as a secret reference in Spark configuration and environment variables: {{secrets/scope/key}}.
key Changes to this property will trigger replacement. String
(String) key within secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
lastUpdatedTimestamp Integer
(Integer) time secret was updated
scope Changes to this property will trigger replacement. String
(String) name of databricks secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
stringValue Changes to this property will trigger replacement. String
(String) super secret sensitive value.
configReference string
(String) value to use as a secret reference in Spark configuration and environment variables: {{secrets/scope/key}}.
key Changes to this property will trigger replacement. string
(String) key within secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
lastUpdatedTimestamp number
(Integer) time secret was updated
scope Changes to this property will trigger replacement. string
(String) name of databricks secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
stringValue Changes to this property will trigger replacement. string
(String) super secret sensitive value.
config_reference str
(String) value to use as a secret reference in Spark configuration and environment variables: {{secrets/scope/key}}.
key Changes to this property will trigger replacement. str
(String) key within secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
last_updated_timestamp int
(Integer) time secret was updated
scope Changes to this property will trigger replacement. str
(String) name of databricks secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
string_value Changes to this property will trigger replacement. str
(String) super secret sensitive value.
configReference String
(String) value to use as a secret reference in Spark configuration and environment variables: {{secrets/scope/key}}.
key Changes to this property will trigger replacement. String
(String) key within secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
lastUpdatedTimestamp Number
(Integer) time secret was updated
scope Changes to this property will trigger replacement. String
(String) name of databricks secret scope. Must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.
stringValue Changes to this property will trigger replacement. String
(String) super secret sensitive value.

Import

The resource secret can be imported using scopeName|||secretKey combination. This may change in future versions.

bash

$ pulumi import databricks:index/secret:Secret app `scopeName|||secretKey`
Copy

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

Package Details

Repository
databricks pulumi/pulumi-databricks
License
Apache-2.0
Notes
This Pulumi package is based on the databricks Terraform Provider.