Skip to content

Instantly share code, notes, and snippets.

@frodera
Last active April 15, 2019 06:03
Show Gist options
  • Save frodera/57906321a98a8939712321899d7fc475 to your computer and use it in GitHub Desktop.
Save frodera/57906321a98a8939712321899d7fc475 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from datetime import datetime
from airflow import DAG
from airflow.operators import BashOperator
from airflow.contrib.operators.ecs_operator import ECSOperator
from acme.utils.datetime import LOCAL_TZ
DAG_ID = 'dag_test_ecs'
bash_command_list = ["uname","-a","&&","python", "-V"]
bash_command_txt = " ".join(bash_command_list)
ecs_operator_args = {
'launch_type': "FARGATE",
'task_definition': "airflow-ecs-task-definitions-test",
'cluster': "airflow-fargate",
'overrides': {
'containerOverrides': [
{
'name': "base-python",
'command': bash_command_list
},
],
},
'network_configuration': {
'awsvpcConfiguration': {
'subnets': [ 'subnet-6fe8c30b' ]
}
}
}
with DAG(
DAG_ID,
start_date=datetime(2017, 9, 14).astimezone(LOCAL_TZ),
schedule_interval=None,
catchup=False
) as dag:
shell_uname_task = BashOperator(
task_id='bash_uname',
bash_command=bash_command_txt,
dag=dag,
)
ecs_uname_task = ECSOperator(
task_id='ecs_uname',
**ecs_operator_args)
shell_uname_task >> ecs_uname_task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment