Setup - Single-User Cluster Encryption¶
This guide provides instructions for setting up Privacera Encryption on Databricks Unity Catalog single-user clusters using Java UDFs.
Prerequisites
Before starting, ensure all Common Prerequisites are fulfilled or verified.
Step 1: Create Init Script¶
Create an init script based on your deployment type.
- Open Databricks Web UI
- Navigate to Workspace files
- Create an init script file (e.g.,
/Workspace/Shared/encryption/init_script.sh) with the following content:
Note
- Replace
<DEPLOYMENT_ENV_NAME>with the same value as configured invars.privacera.ymlat Privacera Manager host. - Replace
<deployment_path>with your actual deployment path. - Ensure
custom-varshasvars.databricks.plugin.ymlwithDATABRICKS_MANAGE_INIT_SCRIPT: "true".
- Navigate to Privacera Portal
- Go to Application > Databricks
- Download the script
privacera_databricks.sh - Modify the script by commenting out the following lines:
- Add the following content at the end of the script:
Note
Ensure encryption is enabled under account settings in Privacera Portal.
Step 2: Create Single-User Cluster¶
- In Databricks, create a new single-user cluster
- Add the init script:
- Select Workspace
- Enter the path to your init script (e.g.,
/Workspace/Shared/encryption/init_script.sh)
- Save and start the cluster
- Wait for the cluster to start successfully
Step 3: Create UDFs¶
Once the cluster is running with the Privacera init script, execute the following SQL commands to create the UDFs.
Note
This is a one-time setup that can be executed from any cluster with the init script.
Create Database¶
| SQL | |
|---|---|
Create UDFs¶
Check if functions exist, drop them if they do, then create new ones:
Step 4: Create Scheme Policy¶
Add a scheme policy so that users, groups, or roles can call the encryption UDFs. Without this policy, calls to protect, unprotect, or mask will be denied.
- In Privacera Portal, go to Access Management > Scheme Policies
- Choose the PEG service context
- Click Add New Policy
- Enter a policy name and description
- Select the target encryption (and optionally presentation or masking) scheme(s)
- Assign Protect and Unprotect to the users, groups, or roles that will run the UDFs; if using masking, also assign Mask
- Save the policy
Step 5: Using Encryption UDFs¶
Encrypt Data¶
| SQL | |
|---|---|
Decrypt Data¶
Without presentation scheme:
| SQL | |
|---|---|
With presentation scheme:
| SQL | |
|---|---|
Mask Data¶
| SQL | |
|---|---|
- Prev topic: Prerequisites
- Next topic: Setup - Shared Cluster