Environment variables
Your Lair can reference environment variables on process execution. For additional security, you can add both an .env or .secrets file. Your .secrets file should be used for any sensitive data, such as private keys, as it is end-to-end encrypted.

Example .env & .secrets files

1
# my-lair-a > .env
2
USER=nihar
3
VERSION=1.0.3
4
5
# my-lair-a > .secrets (example only, data is end-to-end encrypted)
6
API_KEY=hfy92kadHgkk29fahjsu3j922v9sjwaucahf
Copied!

Creating environment variables

First, create an .env or .secrets file in your Lair by selecting the (+) icon or manually initializing an empty file.
Open the .env or .secrets file from your Lair file system. Select “+ Add New Env/Secret” and enter a key and value for your environment variable.
To maintain strict security practices, environment variables added to the .secrets file cannot be modified after creation. Additionally, creating new variables within your .secrets file will require a network connection to avoid local persistence of any unencrypted data.

Accessing environment variables

Environment variables are injected into your Lair’s environment during process execution, and can be accessed using standard os libraries.

Python example

1
### main.py
2
import os
3
4
# Get environment variable values
5
USER = os.getenv('USER')
6
KEY = os.environ.get('API_KEY')
7
8
# Getting non-existent keys
9
FOO = os.getenv('FOO') # None
10
BAR = os.environ.get('BAR') # None
11
BAZ = os.environ['BAZ'] # KeyError: key does not exist.
Copied!

Security considerations

Your .secrets file is end-to-end encrypted and we employ the leading data practices to keep your sensitive data secure. Please see Security for more details.
Last modified 2mo ago