For a full deployment and all the code locations it contains. This approach makes variables available for all code locations in a full Dagster Cloud deployment. As values are pulled from the user cluster, values will bypass Dagster Cloud entirely.
Editor or Admin. Note: Editors and Admins can only set environment variables in full deployments where you're an Editor or Admin.
Setting environment variables for specific code locations is accomplished by adding them to your agent's configuration in your project's dagster_cloud.yaml file. The container_context property in this file sets the variables in the agent's environment.
Using the container_context.ecs.env_vars and container_context.ecs.secrets properties, you can configure environment variables and secrets for a specific code location.
A list of keys or key-value pairs to include in the task. If a value is not specified, the value will be pulled from the agent task. In the example above, FOO_ENV_VAR will be set to foo_value and BAR_ENV_VAR will be set to whatever value it has in the agent task.
A list of tag names. Each secret tagged with any of those tag names in AWS Secrets Manager will be included in the launched tasks as environment variables. The name of the environment variable will be the name of the secret, and the value of the environment variable will be the value of the secret.
After you've modified dagster_cloud.yaml, redeploy the code location in Dagster Cloud to apply the changes:
Using the container_context.docker.env_vars property, you can include environment variables and secrets in the Docker container associated with a specific code location. For example:
The container_context.docker.env_vars property is a list, where each item can be either KEY or KEY=VALUE. If only KEY is specified, the value will be pulled from the local environment.
After you've modified dagster_cloud.yaml, redeploy the code location in Dagster Cloud to apply the changes:
Using the container_context.k8s.env_vars and container_context.k8s.env_secrets properties, you can specify environment variables and secrets for a specific code location. For example:
A list of environment variable names to inject into the job, formatted as KEY or KEY=VALUE. If only KEY is specified, the value will be pulled from the current process.
env_secrets
A list of secret names, from which environment variables for a job are drawn using envFrom. Refer to the Kubernetes documentation for more info.
After you've modified dagster_cloud.yaml, redeploy the code location in Dagster Cloud to apply the changes:
Setting environment variables for full deployments#
If you're a Dagster Cloud Editor or Admin, you can only set environment variables for full deployments where you're an Editor or Admin.
Setting environment variables for a full deployment will make the variables available for all code locations in the full deployment. Using this approach will pull variable values from your user cluster, bypassing Dagster Cloud entirely.
Click the tab for your agent type to view instructions.
To make environment variables accessible to a full deployment with an Amazon ECS agent, you'll need to modify the agent's CloudFormation template as follows:
Sign in to your AWS account.
Navigate to CloudFormation and open the stack for the agent.
Click Update.
Click Edit template in designer.
In the section that displays, click View in Designer. The AWS template designer will display.
In the section displaying the template YAML, locate the AgentTaskDefinition section:
In the user_code_launcher.config portion of the AgentTaskDefinition section, add the environment variables as follows:
To make environment variables accessible to a full deployment with a Docker agent, you'll need to modify your project's dagster.yaml file.
In the user_code_launcher section, add an env_vars property as follows:
# dagster.yamluser_code_launcher:module: dagster_cloud.workspace.docker
class: DockerUserCodeLauncher
config:networks:- dagster_cloud_agent
env_vars:- SNOWFLAKE_PASSWORD # value pulled from agent's environment- SNOWFLAKE_USERNAME=dev
In env_vars, specify the environment variables as keys (SNOWFLAKE_PASSWORD) or key-value pairs (SNOWFLAKE_USERNAME=dev). If only KEY is provided, the value will be pulled from the agent's environment.
To make environment variables to a full deployment with a Kubernetes agent, you'll need to modify and upgrade the Helm chart's values.yaml.
In values.yaml, add or locate the workspace value.
Add an envVars property as follows:
# values.yamlworkspace:envVars:- SNOWFLAKE_PASSWORD # value pulled from agent's environment- SNOWFLAKE_USERNAME=dev
In envVars, specify the environment variables as keys (SNOWFLAKE_PASSWORD) or key-value pairs (SNOWFLAKE_USERNAME=dev). If only KEY is provided, the value will be pulled from the local (agent's) environment.