Managing Secrets & Environment Variables
Use Environment Variables inside your notebook to save your confidential information from getting exposed.
Secrets in Data Science Lab (DSLab) allow users to securely store and manage confidential information, such as API keys, database credentials, and other sensitive parameters. These secrets can be added to notebooks as environment variables, ensuring that sensitive data is not exposed in the code.
Configuring Secret Management in Data Science Lab
Overview
Secret Management in Data Science Lab (DSLab) allows administrators to securely store sensitive information, such as API keys, database credentials, or other confidential parameters. Once configured, secrets can be shared with specific user groups and accessed within notebooks as environment variables.
Note: The secret key name shown in the illustrations is an example. The actual secret key name must be configured by the administrator for production use.
Pre-requisites:
Before accessing secrets in a workspace:
The Secret Management must be configured via the Admin module of the platform.
Configured secrets must be shared with a user group.
The user account performing this activity must belong to the same user group with access to the shared secrets.
Steps to Configure Secret Management
Navigation path: Admin Module > Configurations > Secret Management
Navigate to the Admin module from the platform.
Open the Secret Management option under the configuration panel.
Add a Secret Key name for the confidential data you want to manage.
Insert the field values for the added Secret Key (e.g., username, password, token).
Click Save to persist the secret configuration.
Adding a Secret Key
Navigation path: Data Science Lab > Project > Workspace > left-side panel > Secrets
Access a Data Science Notebook from a user account that is part of the User Group with which the secret is shared.
Open the Secrets tab from the left-side panel of the notebook.
Click the Refresh icon to load the latest configured secret keys.
The newly added secret keys are listed below.
Click the Secret Key you want to add.
Click the drop-down icon next to the Secret Key name to view its fields.
Using Secrets in a Notebook
Open a notebook from the Repo folder.
Add a new code cell in the notebook.
Select the required Secret Key fields using the provided checkboxes.
The system generates encrypted environment variables for the selected fields in the code cell.
Mapping Secrets to Database Writers
Add another code cell.
Open the Writers tab.
Select the writer type (e.g., MySQL) using the checkbox.
Map the encrypted secret keys to the writer configuration details, such as:
Username
Password
Port
Host
Database
Run the code cell to write the data frame to the selected database using the mapped secrets.