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.

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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인