Reputation: 794
I have an activity in step function with TimeoutSeconds
, like this:
ActivityWaiting:
Type: Task
ResultPath: $.output
Resource: arn:aws:states:#{AWS::Region}:#{AWS::AccountId}:activity:myActivity
TimeoutSeconds: 3600
I would like to control the value of TimeoutSeconds
and to change it with a parameter from the previous step.
I've tried something like that:
ActivityWaiting:
Type: Task
ResultPath: $.output
Resource: arn:aws:states:#{AWS::Region}:#{AWS::AccountId}:activity:myActivity
TimeoutSeconds: $.myTimeout
But unfortunately, it didn't work.
Edit:
I would like to calculate/define the time myTimeout
before executing the step function with python. Something like that:
data['myTimeout'] = getTimeout() #dymanic time in the seconds(ex 15000)
response = step_functions.start_execution(stateMachineArn=state_machine, input=json.dumps(data))
Upvotes: 5
Views: 1831
Reputation: 346
This feature is available now. There is a TimeoutSecondsPath
parameter that can be used instead of TimeoutSeconds
. TimeoutSecondsPath
accepts a reference path (e.g. "$.myTimeout"
)
Upvotes: 6
Reputation: 794
Since I couldn't find a solution for dynamic timeout.
I've made a workaround using AWS Choice state
I was needed to wait for an answer from a microservice, the time depended on the quantity of objects, which I've sent to it. Process of each object took like 3 minutes in average, therefore the timeout could be from 3 minutes and more.
All the results, my microservice has written into a DB. So I created a lambda, that checks the DB in a loop.
The exit condition is
I work with Serverless framework, here is my final solution:
VerifyLambda:
Type: Task
Resource: arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:verify-step
Next: IsFinished
IsFinished:
Type: Choice
Choices:
- Variable: $.isFinish
BooleanEquals: false
Next: Wait 3m
Default: NextLambdaStep
Wait 3m:
Type: Wait
Seconds: 180
Next: VerifyLambda
NextLambdaStep: ...
Upvotes: 1