GitHub user aeroyorch created a discussion: Configure Flask app settings via 
prefixed environment variables in FAB provider

During the review of #58293, a discussion came up around how the Airflow 
webserver Flask application is configured. At the moment, Flask-specific 
settings/behaviour are mainly provided through `webserver_config.py`.

This discussion is intended as a follow-up to explore whether Airflow should 
optionally support a second way of configuring some Flask app settings, using 
prefixed environment variables via 
[app.config.from_prefixed_env()](https://flask.palletsprojects.com/en/stable/config/#configuring-from-environment-variables)
 (Flask-Limiter also [honors Flask’s configuration 
values](https://flask-limiter.readthedocs.io/en/stable/configuration.html#using-flask-config).).

# Motivation

Using `app.config.from_prefixed_env()` would allow selected Flask configuration 
options to be provided via environment variables, for example:

```text
AIRFLOW__FLASK__RATELIMITER_STORAGE_URI=${AIRFLOW__CELERY__BROKER_URL}
```

This approach can be useful not only in the Airflow Helm chart, but more 
generally in declarative deployments where configuration is defined via 
environment variables and overridden per environment without changing Python 
files. It can also help avoid introducing imperative logic or 
environment-specific conditionals in code, which can make it harder to 
understand which configuration applies in a given setup. In addition, sensitive 
parts of the configuration can be managed separately using secrets.

At the same time, this is a proposal, and some users may not see additional 
value if their current setup already meets their needs.

# Proposal

Allow the webserver to optionally load some Flask configuration values from 
environment variables using `app.config.from_prefixed_env()`, with a clear 
prefix such as `AIRFLOW__FAB__`, or even a more specific namespace (e.g. 
`AIRFLOW__FAB__FLASK_SETTINGS`, `AIRFLOW__FAB__FLASK_CONFIG`, 
`AIRFLOW__FAB__CONFIG`).

This mechanism would not replace `webserver_config.py`, which would continue to 
be the primary configuration mechanism. When both approaches are used, 
`webserver_config.py` would have precedence over environment-based 
configuration.

GitHub link: https://github.com/apache/airflow/discussions/60048

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to