@@ -46,6 +46,15 @@ class ECSOperator(BaseOperator):
46
46
:type region_name: str
47
47
:param launch_type: the launch type on which to run your task ('EC2' or 'FARGATE')
48
48
:type launch_type: str
49
+ :param group: the name of the task group associated with the task
50
+ :type group: str
51
+ :param placement_constraints: an array of placement constraint objects to use for
52
+ the task
53
+ :type placement_constraints: list
54
+ :param platform_version: the platform version on which your task is running
55
+ :type platform_version: str
56
+ :param network_configuration: the network configuration for the task
57
+ :type network_configuration: dict
49
58
"""
50
59
51
60
ui_color = '#f0ede4'
@@ -55,7 +64,9 @@ class ECSOperator(BaseOperator):
55
64
56
65
@apply_defaults
57
66
def __init__ (self , task_definition , cluster , overrides ,
58
- aws_conn_id = None , region_name = None , launch_type = 'EC2' , ** kwargs ):
67
+ aws_conn_id = None , region_name = None , launch_type = 'EC2' ,
68
+ group = None , placement_constraints = None , platform_version = 'LATEST' ,
69
+ network_configuration = None , ** kwargs ):
59
70
super (ECSOperator , self ).__init__ (** kwargs )
60
71
61
72
self .aws_conn_id = aws_conn_id
@@ -64,6 +75,10 @@ def __init__(self, task_definition, cluster, overrides,
64
75
self .cluster = cluster
65
76
self .overrides = overrides
66
77
self .launch_type = launch_type
78
+ self .group = group
79
+ self .placement_constraints = placement_constraints
80
+ self .platform_version = platform_version
81
+ self .network_configuration = network_configuration
67
82
68
83
self .hook = self .get_hook ()
69
84
@@ -79,13 +94,21 @@ def execute(self, context):
79
94
region_name = self .region_name
80
95
)
81
96
82
- response = self .client .run_task (
83
- cluster = self .cluster ,
84
- taskDefinition = self .task_definition ,
85
- overrides = self .overrides ,
86
- startedBy = self .owner ,
87
- launchType = self .launch_type
88
- )
97
+ run_opts = {
98
+ 'cluster' : self .cluster ,
99
+ 'taskDefinition' : self .task_definition ,
100
+ 'overrides' : self .overrides ,
101
+ 'startedBy' : self .owner ,
102
+ 'launchType' : self .launch_type ,
103
+ 'platformVersion' : self .platform_version ,
104
+ }
105
+ if self .group is not None :
106
+ run_opts ['group' ] = self .group
107
+ if self .placement_constraints is not None :
108
+ run_opts ['placementConstraints' ] = self .placement_constraints
109
+ if self .network_configuration is not None :
110
+ run_opts ['networkConfiguration' ] = self .network_configuration
111
+ response = self .client .run_task (** run_opts )
89
112
90
113
failures = response ['failures' ]
91
114
if len (failures ) > 0 :
0 commit comments