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:
shell
Copied
1
airplane configs set --env stage --secret my_database_url postgresql://my_database
2
airplane configs get my_database_url
3
# For more examples and details
4
airplane 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 word
  • eng/platform/db: use slashes to group your config vars together
  • db: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):
yaml
Copied
1
# my_task.task.yaml
2
rest:
3
configs:
4
# Where API_KEY is the name of a config var created in the web UI.
5
- API_KEY
6
headers:
7
X-API-KEY: "{{configs.API_KEY}}"

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.
typescript
Copied
1
export default airplane.task(
2
{
3
slug: "my_task",
4
envVars: {
5
// Where sendgrid_api_key is the name of a config var.
6
SENDGRID_API_KEY: {config: "sendgrid_api_key"}
7
},
8
},
9
async () => {...}
10
);
This will pass the config var into the task or view as an environment variable. Access environment variables in your script using standard patterns:
typescript
Copied
1
const apiKey = process.env.SENDGRID_API_KEY;

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.
yaml
Copied
1
# airplane.yaml
2
javascript:
3
# These environment variables can be accessed by all JavaScript tasks in the project.
4
envVars:
5
SENDGRID_API_KEY:
6
config: sendgrid_api_key
7
python:
8
# These environment variables can be accessed by all Python tasks in the project.
9
envVars:
10
STRIPE_API_KEY:
11
config: tripe_api_key
12
view:
13
# These environment variables can be accessed by all views in the project.
14
envVars:
15
URL:
16
config: 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