-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guide for setting environment variables in Dagster+ UI (#24012)
## Summary & Motivation Guide for setting env vars in the Dagster+ UI. Largely pulled from the [existing guide](https://docs.dagster.io/dagster-plus/managing-deployments/environment-variables-and-secrets#using-the-dagster-ui) ## How I Tested These Changes ## Changelog [New | Bug | Docs] `NOCHANGELOG` --------- Co-authored-by: Erin Cochran <[email protected]>
- Loading branch information
1 parent
0ae14e1
commit 5ffa931
Showing
4 changed files
with
99 additions
and
8 deletions.
There are no files selected for viewing
94 changes: 92 additions & 2 deletions
94
docs/docs-beta/docs/dagster-plus/deployment/environment-variables/dagster-ui.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,98 @@ | ||
--- | ||
title: "Set environment variables with the Dagster+ UI" | ||
title: "Setting environment variables with the Dagster+ UI" | ||
displayed_sidebar: "dagsterPlus" | ||
sidebar_position: 1 | ||
sidebar_label: "Set with Dagster+ UI" | ||
--- | ||
|
||
# Set environment variables with the Dagster+ UI | ||
Environment variable are key-value pairs that are set outside of your source code. Using environment variables lets you dynamically change the behavior of your application without modifying source code and securely set up secrets. | ||
|
||
Dagster supports several approaches for [accessing environment variable in your code](/todo). You can also set environment variables in several ways, but this guide will focus on the Dagster+ UI. | ||
|
||
## What you'll learn | ||
|
||
- How to add, edit, and delete environment variables in the Dagster+ UI | ||
- How to view the values of environment variables in the Dagster+ UI | ||
- How to export environment variables for local use | ||
- How to modify the value of environment variables based on the deployment environment | ||
|
||
<details> | ||
<summary>Prerequisites</summary> | ||
|
||
To follow the steps in this guide, you'll need: | ||
|
||
- **Organization Admin**, **Admin**, or **Editor** permissions for your Dagster+ account | ||
- To be using Dagster version 1.0.17 or later | ||
|
||
</details> | ||
|
||
## Adding environment variables \{#add} | ||
|
||
Before you begin, use the deployment switcher to select the right deployment. | ||
|
||
1. Click the **+ Add environment variable** button. | ||
2. In the modal that displays, fill in the following: | ||
- **Name** - Enter a name for the environment variable. This is how the variable will be referenced in your code. | ||
- **Value** - Enter a value for the environment variable. | ||
- **Deployment Scope** - select the deployment(s) where the variable should be accessible: | ||
- **Full deployment** - The variable will be available to selected code locations in the full deployment. | ||
- **Branch deployments** - The variable will be available to selected code locations in Branch Deployments. | ||
- **Local** - If selected, the variable will be included when [exporting environment variables to a local `.env` file](#export). | ||
- **Code Location Scope** - select the code location(s) where the variable should be accessible. At least one code location is required. | ||
|
||
|
||
![TODO](/img/placeholder.svg) | ||
|
||
3. Click **Save** | ||
|
||
## Editing environment variables \{#edit} | ||
|
||
On the **Environment variables** page, edit an environment variable by clicking the **Edit** button in the **Actions** column. | ||
|
||
## Deleting environment variables \{#delete} | ||
|
||
On the **Environment variables** page, delete an environment variable by clicking the **Trash icon** in the **Actions** column. | ||
|
||
## Viewing environment variable values \{#view} | ||
|
||
On the **Environment variables** page, view an environment variable by clicking the **eye icon** in the **Value** column. To hide the value, click the **eye icon** again. | ||
|
||
:::note | ||
Viewing an environment variable only reveals the value to you. It doesn't show the value in plaintext to all users. If you navigate away from the environment variables page or reload the page, the value will be hidden again. | ||
::: | ||
|
||
## Exporting environment variables locally \{#export} | ||
|
||
1. On the **Environment variables** page, click the **arrow menu** to the right of the **+ Add environment variable** button. | ||
2. Click **Download local environment variables**. | ||
3. A file named `env.txt` will be downloaded. | ||
|
||
To use the downloaded environment variables for local Dagster development: | ||
|
||
1. Rename the downloaded `env.txt` file to `.env`. | ||
2. Move the file to the directory where you run `dagster dev` or `dagster-webserver`. | ||
3. Run `dagster dev`. | ||
|
||
If the environment variables were loaded successfully, you'll see a log message that begins with `Loaded environment variables from .env file`. | ||
|
||
## Setting environment-dependent variable values \{#environment-dependent-values} | ||
|
||
You can create multiple instances of the same environment variable key with different values, allowing you to provide different values to different deployment environments. For example, you may want to use different Snowflake credentials for your production deployment than in branch deployments. | ||
|
||
When you [add an environment variable](#add), you can select the deployment scope and code location scope for the environment variable. You can create multiple environment variables with different values and different scopes to customize the values in different deployment environments. | ||
|
||
For example, if you wanted to provide different Snowflake passwords for your production and branch deployments, you would make two environment variables with the same key: | ||
|
||
- For the **production** environment variable: | ||
- Set the value as the production password, and | ||
- Check only the **Full deployment** box | ||
- For the **branch deployment** environment variable: | ||
- Set the value as the branch deployment password, and | ||
- Check only the **Branch deployments** box | ||
|
||
SCREENSHOT | ||
|
||
## Next steps | ||
|
||
- Learn how to [access environment variables in Dagster code](/todo) | ||
- Learn about the [built-in environment variables](https://docs.dagster.io/dagster-plus/managing-deployments/environment-variables-and-secrets#built-in-environment-variables) provided by Dagster+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,5 +42,6 @@ we have | |
lookback | ||
Pydantic | ||
DSL | ||
plaintext | ||
vCPU | ||
vCPUs | ||
vCPUs |
5ffa931
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for dagster-docs ready!
✅ Preview
https://dagster-docs-91syoqww9-elementl.vercel.app
https://master.dagster.dagster-docs.io
Built with commit 5ffa931.
This pull request is being automatically deployed with vercel-action