Skip to main content

secrets

Creates, updates, deletes, gets or lists a secrets resource.

Overview​

Namesecrets
TypeResource
Iddatabricks_workspace.workspace.secrets

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
keystring
valuestringThe value of the secret in its byte representation.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectscope, key, deployment_name, workspace_domainGets a secret for a given key and scope. This API can only be called from the DBUtils interface. Users
listselectscope, deployment_name, workspace_domainLists the secret keys that are stored at this scope. This is a metadata-only operation; secret data
putinsertdeployment_name, workspace_domain, scope, keyInserts a secret under the provided scope with the given name. If a secret already exists with the
deleteexecdeployment_name, workspace_domain, scope, keyDeletes the secret stored in this secret scope. You must have WRITE or MANAGE permission on

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
deployment_namestringThe Databricks workspace deployment name: the host prefix of the workspace URL (dbc-abcd0123-a1bc on AWS, adb-1234567890123456.7 on Azure, 1234567890123456.7 on GCP). Set DATABRICKS_DEPLOYMENT_NAME to default it for the session. (default: dbc-abcd0123-a1bc, x-stackQL-envVar: DATABRICKS_DEPLOYMENT_NAME)
keystringName of the secret to fetch value information.
scopestringThe name of the scope to list secrets within.
workspace_domainstringThe Databricks workspace domain suffix for the cloud. Selected by DATABRICKS_CLOUD (aws, azure or gcp; default aws). (default: cloud.databricks.com, x-stackQL-envVarSelector: {"envVar":"DATABRICKS_CLOUD","default":"aws","values":{"aws":"cloud.databricks.com","azure":"azuredatabricks.net","gcp":"gcp.databricks.com"}})

SELECT examples​

Gets a secret for a given key and scope. This API can only be called from the DBUtils interface. Users

SELECT
key,
value
FROM databricks_workspace.workspace.secrets
WHERE scope = '{{ scope }}' -- required
AND key = '{{ key }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
AND workspace_domain = '{{ workspace_domain }}' -- required
;

INSERT examples​

Inserts a secret under the provided scope with the given name. If a secret already exists with the

INSERT INTO databricks_workspace.workspace.secrets (
scope,
key,
bytes_value,
string_value,
deployment_name,
workspace_domain
)
SELECT
'{{ scope }}' /* required */,
'{{ key }}' /* required */,
'{{ bytes_value }}',
'{{ string_value }}',
'{{ deployment_name }}',
'{{ workspace_domain }}'
;

Lifecycle Methods​

Deletes the secret stored in this secret scope. You must have WRITE or MANAGE permission on

EXEC databricks_workspace.workspace.secrets.delete
@deployment_name='{{ deployment_name }}' --required,
@workspace_domain='{{ workspace_domain }}' --required
@@json=
'{
"scope": "{{ scope }}",
"key": "{{ key }}"
}'
;