Skip to content

Commit

Permalink
Merge branch 'current' into dbeatty10-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeatty10 authored Jul 25, 2024
2 parents bc35f38 + 5466bb0 commit 5ca01d4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions website/docs/docs/build/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ Environment variables can be used to customize the behavior of a dbt project dep
[env_var](/reference/dbt-jinja-functions/env_var) for more information on how to call the jinja function `{{env_var('DBT_KEY','OPTIONAL_DEFAULT')}}` in your project code.

:::info Environment Variable Naming and Prefixing
Environment variables in dbt Cloud must be prefixed with either `DBT_` or <VersionBlock lastVersion="1.5">`DBT_ENV_SECRET_`</VersionBlock><VersionBlock firstVersion="1.6">`DBT_ENV_SECRET`</VersionBlock>. Environment variables keys are uppercased and case sensitive. When referencing `{{env_var('DBT_KEY')}}` in your project's code, the key must match exactly the variable defined in dbt Cloud's UI.

Environment variables in dbt Cloud must be prefixed with either `DBT_` or <VersionBlock lastVersion="1.5">`DBT_ENV_SECRET_`</VersionBlock><VersionBlock firstVersion="1.6">`DBT_ENV_SECRET`</VersionBlock> or `DBT_ENV_CUSTOM_ENV_`. Environment variables keys are uppercased and case sensitive. When referencing `{{env_var('DBT_KEY')}}` in your project's code, the key must match exactly the variable defined in dbt Cloud's UI.

:::

### Setting and overriding environment variables
Expand All @@ -20,11 +22,11 @@ Environment variable values can be set in multiple places within dbt Cloud. As a
<Lightbox src="/img/docs/dbt-cloud/using-dbt-cloud/Environment Variables/env-var-precdence.png" title="Environment variables order of precedence"/>

There are four levels of environment variables:
1. the optional default argument supplied to the `env_var` Jinja function in code
2. a project-wide default value, which can be overridden at
3. the environment level, which can in turn be overridden again at
4. the job level (job override) or in the IDE for an individual dev (personal override).

1. The optional default argument supplied to the `env_var` Jinja function in code, which can be overridden at (_lowest precedence_)
2. The project-wide level by its default value, which can be overridden at
3. The environment level, which can in turn be overridden again at
4. The job level (job override) or in the IDE for an individual dev (personal override). (_highest precedence_)

**Setting environment variables at the project and environment level**

Expand All @@ -36,11 +38,12 @@ To set environment variables at the project and environment level, click **Deplo

You'll notice there is a `Project Default` column. This is a great place to set a value that will persist across your whole project, independent of where the code is run. We recommend setting this value when you want to supply a catch-all default or add a project-wide token or secret.

To the right of the `Project Default` column are all your environments. Values set at the environment level take priority over the project-level default value. This is where you can tell dbt Cloud to interpret an environment value differently in your Staging vs. Production environment, as an example.

<Lightbox src="/img/docs/dbt-cloud/using-dbt-cloud/Environment Variables/project-environment-view.png" title="Setting project level and environment level values"/>
To the right of the `Project Default` column are all your environments. Values set at the environmental level take priority over the project-level default value. This is where you can tell dbt Cloud to interpret an environment value differently in your Staging vs. Production environment, as an example.


<Lightbox src="/img/docs/dbt-cloud/using-dbt-cloud/Environment Variables/project-environment-view.png" title="Setting project level and environment level values"/>


**Overriding environment variables at the job level**

Expand All @@ -59,7 +62,7 @@ Every job runs in a specific, deployment environment, and by default, a job will
**Overriding environment variables at the personal level**


You can also set a personal value override for an environment variable when you develop in the dbt integrated developer environment (IDE). By default, dbt Cloud uses environment variable values set in the project's development environment. To see and override these values, click the gear icon in the top right. Under "Your Profile," click **Credentials** and select your project. Click **Edit** and make any changes in "Environment Variables."
You can also set a personal value override for an environment variable when you develop in the dbt-integrated developer environment (IDE). By default, dbt Cloud uses environment variable values set in the project's development environment. To see and override these values, click the gear icon in the top right. Under "Your Profile," click **Credentials** and select your project. Click **Edit** and make any changes in "Environment Variables."

<Lightbox src="/img/docs/dbt-cloud/using-dbt-cloud/Environment Variables/personal-override.gif" title="Navigating to environment variables personal override settings"/>

Expand Down

0 comments on commit 5ca01d4

Please sign in to comment.