Search code examples
amazon-web-servicesairflowmwaa

AWS MWAA (Managed Apache Airflow); Programmatically enable DAGs


We are using AWS MWAA. We add our DAG.py files to our S3 bucket programatically. They then show up in the UI. However, they are "OFF" and you must click the "ON" button to start them.

EDIT: Also we may sometimes want to turn a DAG that's ON to OFF (programatically)

I am looking to do this programmatically, however I cannot figure out to.

The API does not seem to have it: https://docs.aws.amazon.com/mwaa/latest/userguide/mwaa-actions-resources.html

Boto does not seem to have it: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/mwaa.html

Is it possible to manipulate a DAGs status from OFF/ON ON/OFF via API?


Solution

  • This is not doable via API but you can use is_paused_upon_creation this flag specifies if the dag is paused when created for the first time. If the dag exists already, this flag will be ignored.

    You can set is_paused_upon_creation=False in the DAG contractor.

    dag = DAG(
        dag_id='tutorial',
        default_args=default_args,
        is_paused_upon_creation=False,
    )
    

    Another option is to do it via unpause CLI:

    airflow dags unpause [-h] [-S SUBDIR] dag_id