Skip to content

Commit f191497

Browse files
committed
Allow setting Lambda role
Unfortunately, boto2 doesn't support passing lambdaRole; we must override two of its methods (register type and start workflow). Signed-off-by: Yves Bastide <yves@botify.com>
1 parent 08a90ef commit f191497

File tree

4 files changed

+238
-17
lines changed

4 files changed

+238
-17
lines changed

simpleflow/command.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ def transform_input(wf_input):
151151
type=comma_separated_list,
152152
required=False,
153153
help='Tags for the workflow execution.')
154+
@click.option('--lambda-role',
155+
required=False,
156+
help='Lambda role.')
154157
@click.option('--decision-tasks-timeout',
155158
required=False,
156159
help='Timeout for the decision tasks.')
@@ -175,6 +178,7 @@ def start_workflow(workflow,
175178
task_list,
176179
execution_timeout,
177180
tags,
181+
lambda_role,
178182
decision_tasks_timeout,
179183
input,
180184
input_file,
@@ -200,6 +204,7 @@ def start_workflow(workflow,
200204
execution_timeout=execution_timeout,
201205
input=wf_input,
202206
tag_list=tags,
207+
lambda_role=lambda_role or workflow_class.lambda_role,
203208
decision_tasks_timeout=decision_tasks_timeout,
204209
)
205210
print('{workflow_id} {run_id}'.format(
@@ -456,6 +461,9 @@ def create_unique_task_list(workflow_id=''):
456461
type=comma_separated_list,
457462
required=False,
458463
help='Tags identifying the workflow execution.')
464+
@click.option('--lambda-role',
465+
required=False,
466+
help='Lambda role.')
459467
@click.option('--decision-tasks-timeout',
460468
required=False,
461469
help='Decision tasks timeout.')
@@ -490,6 +498,7 @@ def standalone(context,
490498
workflow_id,
491499
execution_timeout,
492500
tags,
501+
lambda_role,
493502
decision_tasks_timeout,
494503
input,
495504
input_file,
@@ -579,6 +588,7 @@ def standalone(context,
579588
task_list,
580589
execution_timeout,
581590
tags,
591+
lambda_role,
582592
decision_tasks_timeout,
583593
json_dumps(wf_input),
584594
None,

simpleflow/workflow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Workflow(Submittable):
3131
version = None
3232
task_list = None
3333
task_priority = None
34+
lambda_role = None
3435

3536
def __init__(self, executor):
3637
self._executor = executor

swf/models/decision/workflow.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ def terminate(self, reason=None, details=None):
5757
def continue_as_new(self, child_policy=None,
5858
execution_timeout=None, task_timeout=None,
5959
input=None, tag_list=None, task_list=None,
60+
lambda_role=None,
6061
workflow_type_version=None):
61-
"""Coninue as new workflow execution decision builder
62+
"""Continue as new workflow execution decision builder
6263
:param child_policy: specifies the policy to use for the
6364
child workflow executions of the new execution
6465
:type child_policy: CHILD_POLICIES.{TERMINATE | REQUEST_CANCEL | ABANDON}
@@ -75,6 +76,9 @@ def continue_as_new(self, child_policy=None,
7576
:param task_list: task list name
7677
:type task_list: str
7778
79+
:param lambda_role: Lambda role
80+
:type lambda_role: str
81+
7882
:param task_timeout: maximum duration of decision tasks for the new workflow execution
7983
:type task_timeout: str
8084
@@ -91,6 +95,7 @@ def continue_as_new(self, child_policy=None,
9195
'input': input,
9296
'tagList': tag_list,
9397
'taskList': task_list,
98+
'lambdaRole': lambda_role,
9499
'workflowTypeVersion': workflow_type_version,
95100
})
96101

@@ -101,7 +106,7 @@ class ChildWorkflowExecutionDecision(Decision):
101106
@decision_action
102107
def start(self, workflow_type, workflow_id, child_policy=CHILD_POLICIES.TERMINATE,
103108
execution_timeout='300', task_timeout='300', control=None,
104-
input=None, tag_list=None, task_list=None):
109+
input=None, tag_list=None, task_list=None, lambda_role=None):
105110
"""Child workflow execution decision builder
106111
107112
:param workflow_type: workflow type to start
@@ -117,6 +122,12 @@ def start(self, workflow_type, workflow_id, child_policy=CHILD_POLICIES.TERMINAT
117122
:param execution_timeout: specifies the total duration for this workflow execution
118123
:type execution_timeout: str
119124
125+
:param task_timeout: maximum duration of decision tasks for the child workflow execution
126+
:type task_timeout: str
127+
128+
:param control: data attached to the event that can be used by the decider in subsequent workflow tasks
129+
:type control: Optional[str]
130+
120131
:param input: The input provided to the child workflow execution
121132
:type input: str
122133
@@ -126,8 +137,8 @@ def start(self, workflow_type, workflow_id, child_policy=CHILD_POLICIES.TERMINAT
126137
:param task_list: task list name
127138
:type task_list: str
128139
129-
:param task_timeout: maximum duration of decision tasks for the child workflow execution
130-
:type task_timeout: str
140+
:param lambda_role: workflow lambda role
141+
:type lambda_role: Optional[str]
131142
132143
"""
133144
if input is not None:
@@ -143,6 +154,7 @@ def start(self, workflow_type, workflow_id, child_policy=CHILD_POLICIES.TERMINAT
143154
'taskList': {
144155
'name': task_list,
145156
},
157+
'lambdaRole': lambda_role,
146158
'workflowId': workflow_id,
147159
'workflowType': {
148160
'name': workflow_type.name,

0 commit comments

Comments
 (0)