Extract, Transform, Load (ETL) on Amazon EMR
This chapter describes orchestration options on Amazon EMR and how to migrate an existing Apache Oozie orchestration application to Amazon MWAA (Managed Workflows for Apache Airflow).
Orchestration on Amazon EMR
Orchestration frameworks are widely used in the Apache Hadoop ecosystem to integrate and monitor multiple applications centrally. They manage complex interdependent jobs, maintain the state of each application, and run based on a predefined pattern.
Apache Oozie is a widely used workflow scheduler. You can also use AWS Step Functions, AWS Glue, or Apache Airflow.
When you migrate from an on-premises Hadoop cluster to Amazon EMR, you must also migrate the orchestration tool so that it can orchestrate applications in the cloud.
This section discusses how to migrate an orchestration application, other orchestration options for Amazon EMR, and recommended best practices.
Migrating Apache Oozie to Amazon MWAA
We recommend migrating from Apache Oozie, because it is no longer under active open-source development and will be removed from an upcoming Amazon EMR release.
If you run Oozie workflows on Amazon EMR, the recommended migration path is Amazon MWAA (Managed Workflows for Apache Airflow). Amazon MWAA is a fully managed Apache Airflow environment that handles the underlying infrastructure and supports Apache Airflow 2.x. It integrates natively with Amazon EMR on Amazon EC2, EMR Serverless, and Amazon EMR on Amazon EKS.
To help with this migration, AWS provides the open-source utility
oozie-to-airflow-emr on GitHub
Migration steps
The following steps describe how to migrate your Oozie workflows to Amazon MWAA.
Step 1: Inventory your Oozie workflows
Take stock of all workflows, coordinators, and bundles. Identify the following:
-
The
workflow.xml,coordinator.xml, and bundle files -
The
job.propertiesfiles and external parameter files -
Dependent libraries and custom actions
-
External database connections or data sources referenced
-
The schedule or trigger mechanism of each coordinator
Step 2: Set up Amazon MWAA
Create an Amazon MWAA environment in the same AWS Region as your EMR clusters. You need an Amazon S3 bucket for DAGs, plugins, and requirements. Create the environment in a VPC with connectivity to your EMR clusters.
#Create an S3 bucket for your MWAA environment aws s3 mb s3://my-mwaa-environment-bucket # Create the required folder structure aws s3api put-object --bucket my-mwaa-environment-bucket --key dags/ aws s3api put-object --bucket my-mwaa-environment-bucket --key plugins/ aws s3api put-object --bucket my-mwaa-environment-bucket --key requirements/
Ensure that the Amazon MWAA execution role has permissions to interact with Amazon EMR, Amazon S3, and other required services.
Step 3: Install and run the oozie-to-airflow-emr conversion utility
Clone the utility and convert your Oozie workflow XML into Airflow DAGs. The utility handles common Oozie constructs, including workflow actions, control flow nodes, and coordinator schedules.
# Clone the conversion utility git clone https://github.com/dgghosalaws/oozie-to-airflow-emr.git cd oozie-to-airflow-emr # Install the required dependencies pip install -r requirements.txt # (Optional) Install from local folder pip install -e.
Requirements: Python >= 3.6 (tested with Python 3.9).
Prepare your application directory structure
The input directory must follow this layout:
<APPLICATION>/ |- job.properties # Job properties used to run the job |- hdfs/ # Folder with application files | |- workflow.xml # Oozie workflow XML (1.0 schema) | |- ... # Additional folders required for HDFS |- configuration.template.properties # Template of configuration values |- configuration.properties # Generated properties for configuration
Configure your environment
Copy configuration.template.properties to
configuration.properties and enter values:
# EMR cluster ID where jobs will run emr_cluster=j-3JT1C4X61EFH # Connection details for Airflow aws_conn_id=aws_default aws_region=us-west-2 check_interval=30 # S3 URI prefix where DAG files and scripts are stored s3_uri_prefix=s3://your-bucket/dags
These values replace Oozie-specific parameters, such as nameNode and
resourceManager, with the AWS connection details that Airflow needs to
interact with Amazon EMR.
Run the conversion
Run the conversion utility to generate the Airflow DAGs:
# Basic conversion o2a -i examples/hive -o output/hive # With additional options o2a -i <INPUT_DIRECTORY_PATH> \ -o <OUTPUT_DIRECTORY_PATH> \ -n <DAG_NAME> \ -u <USER> \ -s <START_DAYS_AGO> \ -v <SCHEDULE_INTERVAL> \ -x <SCHEMA_VERSION>
The following options are available:
-
-i/--input-directory-path(required) -
-o/--output-directory-path(required) -
-n/--dag-name(defaults to input dir name) -
-u/--user(replaces${user.name}, defaults to current user) -
-s/--start-days-ago -
-x/--schema-version[1.0, 0.4, 0.5] -
-v/--schedule-interval(days) -
-d/--dot(renders workflow in DOT format)
Examples for different schema versions
The following examples show conversions for different Oozie schema versions:
# For Oozie schema 0.4 o2a -i examples/order_header_item_stage \ -o output/order_header_item_stage \ -x 0.4 # For Oozie schema 0.5 (Sqoop/Java examples) o2a -i examples/sqoop -o output/sqoop -x 0.5 # For Oozie schema 1.0 (default, Hive/Spark examples) o2a -i examples/spark -o output/spark
Older Oozie workflows might use schema 0.4 or 0.5 with different XML structures, so specify the correct version.
Review the generated DAG
Review each generated DAG carefully. Pay attention to the following:
-
Custom Oozie actions (might need manual refinement)
-
Fork and join constructs (verify parallel execution mapping)
-
Error handling logic (retry and failure callbacks)
-
Parameterization (confirm that
${variables}map to Airflow Variables or Connections) -
Scheduling (coordinator schedules to DAG schedule intervals)
Step 4: Map Oozie constructs to Airflow equivalents
Map each Oozie construct to its Airflow equivalent on Amazon MWAA, as shown in the following table.
| Oozie construct | Airflow equivalent on Amazon MWAA |
|---|---|
| Workflow XML (sequential actions) | Airflow DAG with sequential task dependencies |
| Coordinator (time-based scheduling) | DAG schedule interval or Amazon EventBridge Scheduler |
| Bundle | Multiple DAGs or DAG with sub-DAGs |
| Fork / Join | Airflow TaskGroup with parallel tasks |
| Spark action | EmrServerlessStartJobOperator or
EmrAddStepsOperator |
| Hive action | EmrAddStepsOperator or AWS Glue Job |
| Shell action | BashOperator or AWS Lambda through
AwsLambdaInvokeFunctionOperator |
| Java action | EmrAddStepsOperator with custom JAR |
| Decision node | BranchPythonOperator |
| Kill node | DAG failure handling with on_failure_callback |
Step 5: Update job properties and connection references
Oozie job.properties files contain values, such as
nameNode, resourceManager, and queue names, that are
specific to the on-premises or Amazon EMR on Amazon EC2 environment. In Airflow, you manage these values
through Connections and Variables in the Amazon MWAA environment.
# Example: Referencing EMR connection details using Airflow Variables from airflow.models import Variable from airflow.providers.amazon.aws.operators.emr import ( EmrServerlessStartJobOperator ) emr_serverless_app_id = Variable.get("emr_serverless_app_id") emr_execution_role = Variable.get("emr_execution_role_arn") start_job = EmrServerlessStartJobOperator( task_id='run_spark_job', application_id=emr_serverless_app_id, execution_role_arn=emr_execution_role, job_driver={ 'sparkSubmit': { 'entryPoint': 's3://my-bucket/jobs/my_spark_job.py', 'sparkSubmitParameters': ( '--conf spark.executor.memory=8g ' '--conf spark.executor.cores=4' ) } } )
Step 6: Upload DAGs to the MWAA S3 bucket
Create a dag.zip file that contains the o2a directory
(the utility library) and your generated dag.py file.
# Upload the o2a library directory aws s3 cp o2a/ \ s3://my-mwaa-environment-bucket/dags/o2a/ \ --recursive # Upload the generated DAG file aws s3 cp output/hive/hive.py \ s3://my-mwaa-environment-bucket/dags/ # Create .airflowignore to exclude .o2a files echo ".o2a" > .airflowignore aws s3 cp .airflowignore \ s3://my-mwaa-environment-bucket/dags/
The final Amazon MWAA structure looks like the following:
<airflow-bucket/dags>/ |- .airflowignore # Contains .o2a to be ignored |- o2a/ # Utility library |- dag.py # Generated DAG after conversion
For EC2-based Airflow that uses a packaged DAG, copy the dag.zip file to
the DAG folder in your Airflow installation.
Step 7: Test and validate the migrated workflows
Before you decommission Oozie, run the converted Airflow DAGs in parallel with the existing Oozie workflows. This confirms that outputs match and dependencies resolve. Use the Airflow UI in Amazon MWAA to monitor runs, inspect logs, and troubleshoot.
Validate the following:
-
Output data in Amazon S3 matches what Oozie produced.
-
Scheduling behavior matches the coordinator configuration.
-
Error handling and retry logic behaves as expected.
-
Downstream dependencies receive data in the expected format and location.
Step 8: Decommission Oozie workflows
After you validate the migrated workflows, disable the Oozie coordinators and workflows. Archive the XML files to Amazon S3 for reference.
# Archive Oozie workflow files to S3 before decommissioning aws s3 cp /path/to/oozie/workflows/ \ s3://my-archive-bucket/oozie-archive/ \ --recursive
Considerations
Keep the following considerations in mind when you migrate from Oozie to Amazon MWAA:
-
The automated conversion handles the most common Oozie action types, but complex custom actions or heavily parameterized workflows might require additional manual effort.
-
Oozie coordinators that rely on data availability triggers can be replicated in Airflow using sensors such as the
S3KeySensor. -
Amazon MWAA stores the Airflow metadata database on your behalf, so there is no external database to manage as with Oozie.
-
If your Oozie workflows currently target Amazon EMR on Amazon EC2 clusters, consider whether migrating the compute target to EMR Serverless makes sense at the same time.
AWS services for orchestration
AWS services can create orchestration for Hadoop-based jobs. The following are popular options.
AWS Step Functions
AWS Step Functions lets you coordinate multiple AWS services into serverless workflows. A workflow is a series of steps, where the output of one step is the input to the next step. You can monitor each step, and Step Functions automatically triggers, tracks, and retries steps.
You can connect to Amazon EMR from Step Functions to build data processing and analytics workflows. By using Amazon EMR Service Integration APIs, a state machine can do the following:
-
Create or terminate your Amazon EMR cluster, or submit jobs directly to an Amazon EMR Serverless application. You can reuse the same cluster or application, or create resources on demand.
-
Add or cancel an Amazon EMR step. Each step is a unit of work. You can submit Apache Spark, Apache Hive, or Trino jobs, create dependencies between steps, or run steps in parallel.
-
Modify the size of an Amazon EMR cluster. You can scale Amazon EMR programmatically for each workflow step.
-
Use Express Workflows for high-frequency, short-duration ETL tasks at significantly lower cost than Standard Workflows.
Figure 24: Multiple Apache Spark jobs orchestrated with AWS Step Functions
For more information, see the blog posts Using
Step Functions to Orchestrate Amazon EMR Workloads
AWS Glue Workflows
AWS Glue Workflows provides a visual interface for building and monitoring ETL pipelines. It integrates natively with AWS Glue jobs, crawlers, and Data Quality, and it can trigger Amazon EMR Serverless jobs through Amazon EventBridge integration. AWS Glue Workflows is well suited for organizations that are already invested in the AWS Glue ecosystem. These organizations want straightforward AWS native orchestration without the complexity of a full workflow engine.
Other orchestration options
Some open-source applications have gained popularity because of community adoption. This section covers Apache Airflow and how you can use it on AWS.
Apache Airflow and Amazon MWAA
Apache Airflow is an open-source task scheduler that helps you manage ETL tasks. You can schedule and manage workflows from one central location. With the Configuration as Code approach in Airflow, you can automate the generation of workflows, ETL tasks, and dependencies. This lets developers focus on business problems instead of building and debugging pipelines.
Amazon MWAA (Managed Workflows for Apache Airflow) is a fully managed service that runs Apache Airflow on AWS without the operational overhead of managing infrastructure. Amazon MWAA supports Apache Airflow 3.x and scales workers automatically. It includes connectors that integrate with Amazon EMR on Amazon EC2, Amazon EMR Serverless, and Amazon EMR on Amazon EKS.
For more information, see the AWS Big Data Blog posts Build
a Concurrent Data Orchestration Pipeline Using Amazon EMR and Apache Livy
Best practices for orchestration
Consider the following points when you build robust, fault-tolerant orchestration for Hadoop-based jobs. Like Hadoop, an orchestration tool must be scalable. It must handle a massive number of jobs and scale with Hadoop.
We recommend the following best practices:
-
Most orchestration applications use a default embedded database for job metadata. For production, use a separate database for better performance and availability.
-
When possible, use serverless or managed orchestration services to reduce manual involvement.
-
Integrate with notification services, such as Amazon SNS and Amazon CloudWatch, so that parties are notified on failure.
-
Ensure that the orchestration application handles both asynchronous and synchronous job and task execution.
-
Monitor job execution and management centrally.
-
Ensure that the application handles failure gracefully.
-
If you use Amazon MWAA, select the appropriate environment class and enable worker auto-scaling for production.
-
Tag all Amazon EMR resources with cost allocation tags to support chargeback and showback in multi-tenant environments.
-
Store workflow definitions in a version-controlled repository, and deploy them through a CI/CD pipeline.
To determine the most appropriate orchestration application for your use case, use the following table.
| Factors/Use Cases | AWS Step Functions | Amazon MWAA (Airflow) | AWS Glue Workflows | Apache Oozie |
|---|---|---|---|---|
| Serverless | Yes | No (managed) | Yes | No |
| Spark-based jobs | Yes | Yes | Yes | Yes |
| Rich UI and troubleshooting tools | Yes | Yes | Limited | No |
| Integration with other monitoring tools | Yes | Yes | Limited | No |
| Interacting with AWS services | Extensive | Good | Deep AWS native | Very Limited |
| EMR Serverless support | Yes | Yes | Yes | No |
| Administrative responsibilities | Serverless | Medium | Serverless | High |
| Hybrid environment (AWS and non-AWS services) | Only in the cloud | Broad coverage | AWS only | Hadoop only |