Run the ingestion from AWS MWAA
When running ingestion workflows from MWAA we have three approaches:- Install the openmetadata-ingestion package as a requirement in the Airflow environment. We will then run the process using a
PythonOperator - Configure an ECS cluster and run the ingestion as an
ECSOperator. - Install a plugin and run the ingestion with the
PythonVirtualenvOperator.
Ingestion Workflows as a Python Operator
PROs
- It is the simplest approach
- We don’t need to spin up any further infrastructure
CONs
- We need to install the openmetadata-ingestion package in the MWAA environment
- The installation can clash with existing libraries
- Upgrading the OM version will require to repeat the installation process
requirements.txt file from the MWAA environment to add the following line:
x.y.z is the version of the OpenMetadata ingestion package. Note that the version needs to match the server version. If we are using the server at 1.3.1, then the ingestion package needs to also be 1.3.1.
The plugin parameter is a list of the sources that we want to ingest. An example would look like this openmetadata-ingestion[mysql,snowflake,s3]==1.3.1.
A DAG deployed using a Python Operator would then look like follows
Ingestion Workflow classes
We have different classes for different types of workflows. The logic is always the same, but you will need to change your import path. The rest of the method calls will remain the same. For example, for theMetadata workflow we’ll use:
Metadata:from metadata.workflow.metadata import MetadataWorkflowLineage:from metadata.workflow.metadata import MetadataWorkflow(same as metadata)Usage:from metadata.workflow.usage import UsageWorkflowdbt:from metadata.workflow.metadata import MetadataWorkflowProfiler:from metadata.workflow.profiler import ProfilerWorkflowData Quality:from metadata.workflow.data_quality import TestSuiteWorkflowData Insights:from metadata.workflow.data_insight import DataInsightWorkflowElasticsearch Reindex:from metadata.workflow.metadata import MetadataWorkflow(same as metadata)
Ingestion Workflows as an ECS Operator
PROs
- Completely isolated environment
- Easy to update each version
CONs
- We need to set up an ECS cluster and the required policies in MWAA to connect to ECS and handle Log Groups.
1. Create an ECS Cluster & Task Definition
- The cluster needs a task to run in
FARGATEmode. - The required image is
docker.open-metadata.org/openmetadata/ingestion-base:x.y.z- The same logic as above applies. The
x.y.zversion needs to match the server version. For example,docker.open-metadata.org/openmetadata/ingestion-base:1.3.1
- The same logic as above applies. The
/ecs/openmetadata below when configuring the policies.
2. Task Definition ARN & Networking
- From the AWS Console, copy your task definition ARN. It will look something like this
arn:aws:ecs:<region>:<account>:task-definition/<name>:<revision>. - Get the network details on where the task should execute. We will be using a JSON like:
3. Update MWAA Executor Role policies
- Identify your MWAA executor role. This can be obtained from the details view of your MWAA environment.
- Add the following two policies to the role, the first with ECS permissions:
region, account-id and the log group names for your Airflow Environment and ECS.
4. Prepare the DAG
A DAG created using the ECS Operator will then look like this:pipelineType configuration will need to hold one of the following values:
metadatausagelineageprofilerTestSuite
PipelineType JSON Schema definitions
Moreover, one of the imports will depend on the MWAA Airflow version you are using:
- If using Airflow < 2.5:
from airflow.providers.amazon.aws.operators.ecs import ECSOperator - If using Airflow > 2.5:
from airflow.providers.amazon.aws.operators.ecs import EcsRunTaskOperator
ecs_operator_task task call accordingly.
For the Python VirtualenvOperator approach, see MWAA with Python VirtualenvOperator.