Lesson 3 of 5 Data Pipeline Orchestration

Running Apache Airflow Pipelines with Amazon MWAA

This lesson explains how Amazon Managed Workflows for Apache Airflow (Amazon MWAA) runs Airflow without managing its infrastructure, for teams that already write Airflow DAGs or need its rich scheduling.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe DAGs, tasks and operators.
  • Describe how an MWAA environment is set up.
  • Troubleshoot common MWAA problems.
  • Decide when MWAA is the right orchestrator.

Airflow concepts

Amazon Managed Workflows for Apache Airflow (MWAA) runs Airflow, whose pipelines are built from a few concepts. A DAG, a directed acyclic graph, is a pipeline written in Python that defines its steps and the order between them. Each step is a task. Most tasks are operators, which do something, such as starting a Glue job or running a Redshift query. Sensors are tasks that wait for a condition, such as a file appearing in S3, before later tasks run. The scheduler starts each task once its schedule and its upstream dependencies are met. The following table summarises the concepts.

ConceptMeaning
DAGA pipeline (directed acyclic graph) written in Python
TaskA step in the DAG
OperatorA task that does something
SensorA task that waits for something, such as a file in S3
SchedulerRuns each task when its dependencies and schedule are met
Match the pairs

Airflow vocabulary

Exam skills 3.1.1

Match each Airflow concept with its meaning.

Log in to try this activity Interactive activities are free with an account.

How MWAA is set up

Amazon Managed Workflows for Apache Airflow (MWAA) runs Apache Airflow environments without the customer managing servers. DAG files, which define the pipelines, the requirements.txt file listing Python packages, and any plugins are stored in an S3 bucket, from which MWAA loads them. MWAA runs the Airflow scheduler, auto-scaling workers and the web server inside the customer's VPC, and environment classes, from small to extra large, size the scheduler and workers.

The Amazon provider package for Airflow includes operators and sensors for AWS Glue, Amazon EMR, EMR Serverless, Amazon Athena, Amazon Redshift, Amazon S3, AWS Lambda, AWS Step Functions and Amazon SageMaker AI. Airflow adds retries, backfills that run a DAG for past intervals, SLAs, and connections that can be stored in AWS Secrets Manager.

The following diagram shows where MWAA's files and components sit.

How Amazon MWAA is set up. DAG files, requirements.txt and plugins sit in an S3 bucket, from which the environment loads them. The scheduler, auto-scaling workers and web server run in the customer's VPC, operators from the Amazon provider package call AWS services, and all logs go to CloudWatch.
The operator list shows examples from the Amazon provider package.

Troubleshooting

Problems in Amazon MWAA usually arise from a small number of causes. The following table pairs common symptoms with their likely causes.

SymptomLikely cause
A DAG does not appearAn import error (see DAG processing logs) or a package missing from requirements.txt
Tasks fail calling AWSMissing permissions in the execution role, or VPC networking with no route to endpoints

Scheduler, worker, web server, DAG processing and task logs all go to CloudWatch.

Troubleshooting

MWAA problems

Exam skills 3.1.2

Find the cause of each MWAA problem, choosing again until you find it.

Log in to try this activity Interactive activities are free with an account.
Worked example

Choosing MWAA

A data team already writes its pipelines as Apache Airflow DAGs in Python, with dozens of operators for databases and SaaS tools, and wants to stop running its own Airflow servers.

MWAA
Existing Airflow DAGsRun as they are
Workflow definitionPython code
Cost modelEnvironment runs continuously
Open-source operatorsLarge ecosystem
Step Functions
Existing Airflow DAGsMust be rewritten
Workflow definitionJSON or YAML states
Cost modelPay per state transition
Open-source operatorsAWS service integrations

MWAA fits because the DAGs already exist. A new team starting from scratch, with mostly AWS services to orchestrate and occasional runs, would more likely choose Step Functions. When an MWAA DAG fails to appear, the first checks are the DAG file in the S3 bucket and the dependencies in requirements.txt.

Check yourself

Where are extra Python packages for MWAA DAGs specified?

Show answer

In requirements.txt in the environment's S3 bucket.

Exam Tips

Remember for the exam

  • Existing Airflow DAGs or Airflow skills point to MWAA.
  • Python packages for DAGs go in requirements.txt in the S3 bucket.
  • If a DAG does not appear in the UI, check the DAG processing logs for import errors.
  • To wait for a file before running a task, use an S3 sensor.
  • To re-run a pipeline for past dates, use an Airflow backfill.