Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using an amazon step function, how do I write a choice operator that references current time?

In the aws-step function documentation, it seems possible to write a 'choice' state comparing variables from the current state. However, is it possible to write a timestamp comparison referencing the current time? For example, say I want a particular state to be enabled when the time in my state's $.myTime property is TimestampGreaterThan the [current time]. For example:

{
   "Variable": "$.myTime",
   "TimestampGreaterThan": "<the current time>",
   "Next": "MyTimeSpecificState"
}

Is it possible to reference the current time, or do I have to manually set that on the state in a separate task?

like image 666
Blake Avatar asked Sep 28 '17 04:09

Blake


People also ask

What is $$ in Step Functions?

$ to the end, as you do when selecting state input with a path. Then, to access context object data instead of the input, prepend the path with $$. . This tells AWS Step Functions to use the path to select a node in the context object.

Can we schedule Step Functions AWS?

From this stream, you can create rules to route specific events to AWS Step Functions and invoke a state machine to perform further processing. AWS Step Functions allows you to coordinate multiple services into serverless workflows so you can build and update automated processes quickly.


1 Answers

Yes, it is currently (as of 2020) possible by using the Context Object ($$), here's how:

{
   "Variable": "$.myTime",
   "TimestampGreaterThan": "$$.State.EnteredTime",
   "Next": "MyTimeSpecificState"
}

Here's the link to the AWS Step Functions Developers Guide: Context Object.

like image 53
JN01 Avatar answered Oct 13 '22 20:10

JN01