How do I store a SQL connection password in Airflow cfg?

Viewed 426

In the .cfg file, I connected sql alchemy to Postgres with user: airflow_admin and password: pass: sql_alchemy_conn = postgresql+psycopg2://airflow_admin:pass@localhost:5432/airflow_backend

How do I anonymize this so that the password doesn't show? Do I create a .env file and store the password as a variable and then reference that variable in .cfg conn string?

I read the following but an example would be helpful: https://airflow.readthedocs.io/en/stable/howto/set-config.html

1 Answers

There are several way to do it: 1. change the configuration file permision to read only by airflow account 2. used airflow by docker mode, and encrpyt the configurationfile by docker secret create and map it.

THe mode 1 is easy and convinent. The mode 2 is flexible and can be used in production environment.

Good luck.

If you think the answer is good, pls up vote

Related