Skip to main content
Mage allows users to interpolate variables specific to your pipeline or project. The following syntax is specific to yaml and SQL files. Here’s a list of the different variables and functions you can use in your code:
SyntaxDescription
{{ env_var('secret') }}Get secret from environment variables.
{{ variables('secret') }}Get secret from runtime variables.
{{ mage_secret_var('secret') }}Get secret from Mage secrets.
{{ aws_secret_var('secret') }}Get secret from AWS Secrets Manager.
{{ azure_secret_var('secret') }}Get secret from Azure Key Vault.
{{ doppler_secret_var('secret') }}Get secret from Doppler.
{{ json_value(json_obj, 'key') }}Extract value from a JSON string.
{{ n_days_ago(N) }}Get the date N days ago (data integration pipelines only).

Mage Pro only variable syntax

SyntaxDescription
{{ file('path/to/file.txt') }}Load the contents of a local file.

File content syntax

This is useful for dynamically loading configuration files, secrets, or text assets during pipeline execution. The path can be either absolute path or relative path to the project. Example Usage
{{ file('secrets.txt') }}`
{{ file('/home/src/default_repo/settings.json') }}`
If you want to get a json field from the local file, you can use it together with the json_value syntax like
{{ json_value(file('path/to/file.json'), 'key') }}`

Doppler secrets syntax

Use doppler_secret_var to read a secret directly from Doppler when the template is rendered:
{{ doppler_secret_var('POSTGRES_PASSWORD') }}
Mage reads the default Doppler project and config from these environment variables:
VariableDescription
DOPPLER_TOKENDoppler token used to read secrets.
DOPPLER_PROJECTDoppler project identifier.
DOPPLER_CONFIGDoppler config name.
DOPPLER_API_HOSTOptional API host. Defaults to https://api.doppler.com.
DOPPLER_SECRETS_CACHE_TTL_SECONDSOptional in-memory cache TTL. Defaults to 10. Set to 0 to refresh on every lookup.
You can override the project or config for an individual reference:
{{ doppler_secret_var('POSTGRES_PASSWORD', project='analytics', config='prd') }}
When a Doppler secret changes, Mage picks up the new value on the next template render after the cache TTL expires. Already-open database connections or clients may continue using the value they were created with until they are recreated.