I get the following error when Airflow tries to import my DAG file on MWAA:
Broken DAG: [/usr/local/airflow/dags/file.py] Traceback (most recent call last):
File "/usr/local/airflow/.local/lib/python3.11/site-packages/airflow/hooks/base.py", line 72, in get_connection
conn = Connection.get_connection_from_secrets(conn_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/airflow/.local/lib/python3.11/site-packages/airflow/models/connection.py", line 477, in get_connection_from_secrets
raise AirflowNotFoundException(f"The conn_id `{conn_id}` isn't defined")
airflow.exceptions.AirflowNotFoundException: The conn_id `test` isn't defined
However, the connection was clearly defined in the Web UI:
We try to access the connection like this in the DAG file:
from airflow.providers.mysql.hooks.mysql import MySqlHook
mysql_hook = MySqlHook(mysql_conn_id='test')
Locally, in our Airflow development environment everything works fine, so we can exclude any issues related to the code.