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.

Steps to Configure Secret Management

Navigation path: Admin Module > Configurations > Secret Management

  1. Navigate to the Admin module from the platform.

  2. Open the Secret Management option under the configuration panel.

  3. Add a Secret Key name for the confidential data you want to manage.

  4. Insert the field values for the added Secret Key (e.g., username, password, token).

  5. Click Save to persist the secret configuration.

Notes:

  • The actual Secret key name must be provided or configured by the administrator. A sample key name may be displayed in images or examples, but should not be used in production.

  • The administrator is responsible for providing the exact secret key name.

  • Once saved, the secret key can be shared with a user group, enabling members of that group to access the secrets inside the Data Science Lab module.

Adding a Secret Key

Navigation path: Data Science Lab > Project > Workspace > left-side panel > Secrets

  1. Access a Data Science Notebook from a user account that is part of the User Group with which the secret is shared.

  2. Open the Secrets tab from the left-side panel of the notebook.

  3. Click the Refresh icon to load the latest configured secret keys.

  4. The newly added secret keys are listed below.

  5. Click the Secret Key you want to add.

  6. Click the drop-down icon next to the Secret Key name to view its fields.

Using Secrets in a Notebook

  1. Open a notebook from the Repo folder.

  2. Add a new code cell in the notebook.

  3. Select the required Secret Key fields using the provided checkboxes.

  4. The system generates encrypted environment variables for the selected fields in the code cell.

Mapping Secrets to Database Writers

  1. Add another code cell.

  2. Open the Writers tab.

  3. Select the writer type (e.g., MySQL) using the checkbox.

  4. Map the encrypted secret keys to the writer configuration details, such as:

    • Username

    • Password

    • Port

    • Host

    • Database

  5. Run the code cell to write the data frame to the selected database using the mapped secrets.

Notes:

  • The secret keys are encrypted to ensure confidentiality and cannot be viewed directly in the notebook.

  • Only users who have been granted access via User Groups can view and use the secret keys in notebooks.

  • Using Secrets avoids hardcoding sensitive information in code, improving security and maintainability.