Hey Team has anyone tried installing Meltano insid...
# troubleshooting
a
Hey Team has anyone tried installing Meltano inside an Airflow container and make it work ? I have been having the issue for long and wondering if the community did something similar ? . Here’s a git issue I created on the Meltano project explaining the problem and whatever I was able to debug - https://github.com/meltano/meltano/issues/6373
e
why would you want to install meltano in another container? just run two containers.. or am I missing something? Also.. meltano comes with the ability to install its own airflow.. are you trying to connect your meltano to that pre-existing airflow within a container or..?
a
@emcp: I am planning to run my meltano extracts , loads from airflow . example: the tasks in airflow dags would call tap-salesforce to get salesforce data and later write to a target. Hence the installation of meltano within airflow container. And yes I trying to connecting to my existing airflow setup.
s
I have taken the approach of running Meltano in a stand-along Docker Container then have an Airflow Task execute the meltano run command to move data from Salesforce to your Target. It means Meltano only runs for the period of time required to move the data from the source to the target. Yes, I have done this successfully using the ECSOperator. You may find some of this code example helpful if you want to try a different pattern.
Copy code
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   <http://www.apache.org/licenses/LICENSE-2.0>
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

"""
This is an example dag for ECSOperator.

The task "meltano" runs `meltano` task in `<my_cluster_name>` cluster.
It overrides the command in the `Meltano` container.
"""

import datetime
import os

from airflow import DAG
from airflow.providers.amazon.aws.operators.ecs import ECSOperator

dag = DAG(
    dag_id="Salesforce_Testing",
    default_args={
        "owner": "airflow",
        "depends_on_past": False,
        "email": ["<your email address for failures>"],
        "email_on_failure": True,
        "email_on_retry": True,     
    },
    default_view="graph",
    schedule_interval=None,
    start_date=datetime.datetime(2020, 1, 1),
    tags=["example"],
)
# generate dag documentation
dag.doc_md = __doc__

# [START howto_operator_ecs]
airflow_logging_test = ECSOperator(
    task_id="Meltano_Salesforce_to_Target",
    dag=dag,
    aws_conn_id="aws_ecs",
    cluster="<my_cluster_name>",
    task_definition="<my_task_definition_name>",
    launch_type="FARGATE",
    region_name="<insert aws region>",
    overrides={
        "containerOverrides": [
            {
                "name": "meltano",
                "command": ["chamber", "exec", "meltano/tap-salesforce", "meltano/target-snowflake", "--", "meltano", "elt", "tap-salesforce", "target-snowflake", "state-id=tap_salesforce_to_target_snowflake"],
            },
        ],
    },
    network_configuration={
        "awsvpcConfiguration": {
            "securityGroups": [os.environ.get("SECURITY_GROUP_ID", "mymeltano-containersecuritygroup")],
            "subnets": [
                os.environ.get("AIRFLOW__CORE__VPC_SUBNETA"),
                os.environ.get("AIRFLOW__CORE__VPC_SUBNETB")
            ],
            "assignPublicIp": "DISABLED"
        },
    },
    tags={
        "Customer": "Customer XYZ",
        "Project": "Salesforce to Snowflake",
        "Application": "Meltano",
        "Version": "0.0.1",
        "Environment": "Development",
    },
    awslogs_group="/ecs/meltanologs",
    awslogs_region="<insert aws region>",
    awslogs_stream_prefix="ecs/meltano",  # prefix with container name
)
# [END howto_operator_ecs]