Environment variables
Environment variables, which are key-value pairs configured outside your source code, allow you to dynamically modify application behavior depending on environment.
Using environment variables, you can define various configuration options for your Dagster application and securely set up secrets. For example, instead of hard-coding database credentials - which is bad practice and cumbersome for development - you can use environment variables to supply user details. This allows you to parameterize your pipeline without modifying code or insecurely storing sensitive data.
There are two ways to declare and manage variables in Dagster+:
- Through the Dagster+ UI
- With agent configuration.
Dagster+ UI | Agent configuration | |
---|---|---|
Deployment type support | Serverless, Hybrid | Hybrid |
How it works | Environment variables are managed in the Dagster+ UI. Values are pulled from storage and decrypted when your code is executed. | Environment variables are defined in the agent's configuration. Variables set at the code location level will pass through Dagster+, while those set at the deployment level bypass Dagster+ entirely. For more information, see "Setting environment variables using agent config". |
Requirements |
| Ability to modify your dagster.yaml and dagster_cloud.yaml files |
Limitations |
| Variable names:
|
Storage and encryption | Uses Amazon Key Management Services (KMS) and envelope encryption. For more information, see "Setting environment variables in the Dagster+ UI". | Dependent on agent type. |
Scope | Scoped by deployment (full and branch) and optionally, code location. | Scoped by code location. Variables can be set for a full deployment (all code locations) or on a per-code location basis. |