Config variables
Configs variables ("config vars") allow you to set team-wide values / secrets and use them in tasks and runbooks.
Managing config vars
To manage config vars, you must be a Team Admin. If you're a Team Admin, you can manage them from
the app via the Config vars settings.
Config vars can also be managed from the CLI:
shellCopied1airplane configs set --env stage --secret my_database_url postgresql://my_database2airplane configs get my_database_url3# For more examples and details4airplane configs --help
Config vars have a name and an associated string value. Config vars can be secret, in
which case the value can be set but will not be exposed to users from the UI. All config vars on
Airplane are stored encrypted at rest.
Config var names are flexible, but we recommend the following conventions:
db
: for simple names use lowercase, one wordeng/platform/db
: use slashes to group your config vars togetherdb:stage
: use a colon to append a tag to your config var name—use tags for different variants of a config var (e.g. staging/production). Tags don't have special behavior currently but may get extra features in the future.
Using config vars in tasks and views
You can pass in a config var to a task or view in one of two ways: config attachments and
environment variables.
Config attachments
For SQL, REST and GraphQL tasks, you can use configs
by attaching them to the task and referencing them in a JS template.
In your task definition file (the file with extension
.task.yaml
):yamlCopied1# my_task.task.yaml2rest:3configs:4# Where API_KEY is the name of a config var created in the web UI.5- API_KEY6headers:7X-API-KEY: "{{configs.API_KEY}}"
When creating a task, select the configs that you'd like to attach to the task:

The configs can then be referenced in any templated field in the UI:

Environment variables
For all other task types as well as views, you can utilize configs by creating environment variables
that are populated from config variables.
typescriptCopied1export default airplane.task(2{3slug: "my_task",4envVars: {5// Where sendgrid_api_key is the name of a config var.6SENDGRID_API_KEY: {config: "sendgrid_api_key"}7},8},9async () => {...}10);
javascriptCopied1export default airplane.task(2{3slug: "my_task",4envVars: {5// Where sendgrid_api_key is the name of a config var.6SENDGRID_API_KEY: {config: "sendgrid_api_key"}7},8},9async () => {...}10);
pythonCopied1@airplane.task(2env_vars=[3airplane.EnvVar(4name="SENDGRID_API_KEY",5# Where sendgrid_api_key is the name of a config var.6config_var_name="sendgrid_api_key",7),8],9)10def my_task():11pass
In your task definition file (the file with extension
.task.yaml
):yamlCopied1shell:2envVars:3SENDGRID_API_KEY:4# Where sendgrid_api_key is the name of a config var.5config: sendgrid_api_key
tsxCopied1export default airplane.view(2{3slug: "my_view",4envVars: {5// Where my_url is the name of a config var.6MY_URL: { config: "my_url" },7},8},9MyView10);
Expand the Advanced section, and find the Environment Variables section. Choose
From config variable
to assign a config var's value to the specified environment variable:
This will pass the config var into the task or view as an environment variable. Access environment
variables in your script using standard patterns:
typescriptCopied1const apiKey = process.env.SENDGRID_API_KEY;
javascriptCopied1const apiKey = process.env.SENDGRID_API_KEY;
pythonCopied1api_key = os.getenv('SENDGRID_API_KEY')
bashCopied1api_key=$SENDGRID_API_KEY
tsxCopied1const myURL = process.env.MY_URL;
Project wide environment variables
In addition to setting environment variables on individual tasks and views, you can also set
environment variables for all tasks and views in a
project.
Set project-wide environment variables in your
airplane.yaml
configuration file.yamlCopied1# airplane.yaml2javascript:3# These environment variables can be accessed by all JavaScript tasks in the project.4envVars:5SENDGRID_API_KEY:6config: sendgrid_api_key7python:8# These environment variables can be accessed by all Python tasks in the project.9envVars:10STRIPE_API_KEY:11config: tripe_api_key12view:13# These environment variables can be accessed by all views in the project.14envVars:15URL:16config: my_url
Using environment variables at build time
Environment variables on individual tasks can only be accessed at run-time. If you want to use an
environment variable at build-time, for example when installing dependencies, you can set
Project wide environment variables