MWAA Airflow connection not defined

0

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:

Enter image description here

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.

at_178
已提问 6 个月前321 查看次数
1 回答
0

The name of the parameter is conn_id[1] not mysql_conn_id --the latter is the example string[2].

mysql_hook = MySqlHook(conn_id='test')

[1] https://github.com/apache/airflow/blob/v2-0-stable/airflow/hooks/base.py#L62C16-L62C23

[2] https://github.com/apache/airflow/blob/v2-0-stable/airflow/providers/mysql/hooks/mysql.py#L42

AWS
John_J
已回答 6 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则