2

The plugins "airflow-code-editor" or "simple-dag-editor" are designed to edit dag directly in airflow interface.

Sadly they don't work on MWAA because of a "Read-only file system" error.

Is there a way to make them work ?

Hugo
  • 1,195
  • 2
  • 12
  • 36

1 Answers1

0

With Airflow Code Editor version >= 7.0.0 you can show/edit files on S3.

You have to:

  • create the file "requirements.txt" in the dag bucket with the following content:
airflow-code-editor
black
fs-s3fs
  • in the Amazon MWAA console "DAG code in Amazon S3" section set "Requirements file - optional" to the path of the requirement.txt file
  • in the "Airflow configuration options - optional" section, add an option and set "Configuration option" to code_editor.mount and "Custom value" to name=dags,path=s3://your_bucket (replacing "your_bucket" with the name of your S3 DAGS bucket).
  • in IAM console, edit the Airflow's IAM role and add permission for writing and deleting objects from the bucket
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject*",
                "s3:PutObject*",
                "s3:DeleteObject*",
                "s3:GetBucket*",
                "s3:List*"
            ],
            "Resource": [
                "arn:aws:s3:::your_bucket",
                "arn:aws:s3:::your_bucket/*"
            ]
        },
  • wait until Airflow is upgraded (minutes)
  • in the Airflow tree, now you have a new node "dags" under "Files", you can read/write dags from this folder.
  • Hi Andrea, thanks a lot for you answer ! I tried it right away but it didnt work I have "Error saving order_test.py: operation failed, [Errno 30] Read-only file system: b'/usr/local/airflow/dags/order_test.py'" when I save – Hugo Aug 24 '22 at 07:56
  • I have fs-s3fs airflow-code-editor>=7.0.0 in my requirements.txt and code_editor mount name=dags,path=s3://my_bucket in AirflowUI/configuration – Hugo Aug 24 '22 at 07:59
  • are you the author of airflow-code-editor ? – Hugo Aug 24 '22 at 08:00
  • I saw you edited you message so I tried again but with no success – Hugo Aug 26 '22 at 09:26