Skip to main content
Setting up Environment Variables Setting up Environment Variables

Overview

Environment variables are securely stored in HashiCorp Vault and used to configure your dbt profiles.yml file. This allows you to keep sensitive credentials separate from your code while maintaining secure access to your data sources.

How It Works

When you set up environment variables in TensorStax:
  1. Secure Storage: All environment variables are encrypted and stored in HashiCorp Vault
  2. Automatic Integration: Variables are automatically injected into your dbt runtime environment
  3. Profile Configuration: Your profiles.yml file references these variables using the env_var() function

Setting Environment Variables

Navigate to your dbt project settings and add the required environment variables for your data source connections. Common variables include:
  • Database credentials (username, password)
  • Connection details (account, warehouse, database)
  • Role and schema information

Example profiles.yml Configuration

Here’s how your profiles.yml file would reference the environment variables:
snowflake_dbt_demo:
  outputs:
    dev:
      type: snowflake
      account: "{{ env_var('DBT_SNOWFLAKE_ACCOUNT') }}"
      user: "{{ env_var('DBT_SNOWFLAKE_USER') }}"
      password: "{{ env_var('DBT_SNOWFLAKE_PASSWORD') }}"
      role: "{{ env_var('DBT_SNOWFLAKE_ROLE') }}"
      database: "{{ env_var('DBT_SNOWFLAKE_DATABASE') }}"
      warehouse: "{{ env_var('DBT_SNOWFLAKE_WAREHOUSE') }}"
      schema: "{{ env_var('DBT_SNOWFLAKE_SCHEMA') }}"
      threads: 4
  target: dev

Security Benefits

Encrypted Storage

All environment variables are encrypted at rest in HashiCorp Vault.

Access Control

Role-based access controls determine who can view or modify variables.

Best Practices

Use clear, descriptive names with prefixes to identify the service:
  • DBT_SNOWFLAKE_ACCOUNT
  • DBT_POSTGRES_HOST
  • DBT_BIGQUERY_PROJECT
Regularly rotate sensitive credentials like passwords and API keys for enhanced security.
Only set the environment variables that are actually needed for your dbt project.
Grant environment variable access only to team members who need it for their work.

Next Steps