New Workflow Studio for AWS Step Functions

Yuri Fenyuk
5 min readJul 5, 2021

--

In June’21 AWS released a visual editor for Step Functions introduced 5 years ago. I like pretty much that managed service and have used it as a data flow engine in a couple of projects, so it is a bonus to have the editor available now. In addition, the recent release is a good sign Amazon continues to treat Step Functions seriously.

The current article will be a rather “say hello” to new feature than deep dive into it. AWS News Blog has more information as well as upcoming (let’s leave through summer activity slow down :) ) training and conferences presentations. I am using one of publically available sample to have workable Step Function in couple clicks. Please go to Step Functions > State Machines in AWS Console and click “Create state machine” button.

Choose authoring method

In following screen select the last “Run sample project” radio button and select “Orchestrate Lambda function” and press Next.

Orchestrate Lambda function

On the last wizard window you will see AWS resources which will be created as Cloud Formation stack to make this sample work.

Deploy resources

Click “Deploy resources” and wait few minutes (remember removing just created Cloud Formation when done). After the newly created Step Function named StockTradingStateMachine-XXX should appear in State Machine list.

new Step Function

After opening its details and clicking “Edit” button, the new “Workflow Studio” button appears.

“Workflow Studio” button

Hit it and be amazed by new visual editor appearance and functionality (just in case YAML file definition needed it’s on my github repo).

new visual editor

Let’s spend a minute exploring flow details by selecting each block and seeing details on the right panel. This helps understand the logic behind blocks. Among the interesting blocks:

  • “Check Stock Price”: invokes 1 line Lambda which generates fake stock price from zero to a hundred
  • “Generate Buy/Sell recommendation”: another tiny Lambda to receive price and input and injects “buy” (if the price is less than 50) or “sell” otherwise
  • “Request Human Approval”: sends a message to SQS solely to demo some human dependant action (can be treated as a bypass to the next block for us)

Other blocks are branching logic to do something for buy and others for sell. All blocks have underlying resources (Lambdas, SQS, SNS) created as Cloud Formation stack pieces and can be opened in AWS Console as well.

Probably, it makes sens to see how Step Function works as is. For that, please exit Workflow Studio by clicking “Cancel” followed by “Start Execution” button. Input JSON can be anything. With couple launches, both buy and sell branch execution will be seen.

Buy and Sell executions

Let’s get back to Workflow Studio and visually amend flow. Again, click “Edit” button filled by “Workflow Studio”.

My humble plan will be to get rid of human approval (in fact, emulation in this case) but set spending budget instead and do not allow expensive buying but rather fail whole flow. For that:

  • select in editor block “Request Human Approval” and click “Delete state” in the right bottom area
  • on the left side activate “Flow” tab, drag “Choice” block just above “Buy Stock” Lambda invoke and drop there. This will be the decision block whether there is enough budget to buy stock or whole flow needs to be failed. So far, the affected area should look like following:
Partial flow modification

Time to modify newly added Choice block. For that select it and change State name from “Choice” to “Exceed budget?”. Below name click edit icon for “Rule #1” choice. Now hit “Add Condition” button. the plan is to got this way when buying stock is higher than 20.

  • for Variable enter “$.stock_price”
  • for Operator enter “is greater than or equal”
  • for Value enter “Number constant”
  • for rightmost column enter “20”

“Rule #1” modification is finished. There is no need to change other “Default” rule and it already pointing to “Buy” block which is desired transition when just entered condition is not met.

Next step is to add “Fail” block as the transition when “Rule #1” is true. Final flow should look similar to following:

Final flow modification

Again, just in case the final YAML file is here. Hopefully, the great capabilities of visual editor will be enough and direct YAML interaction will be skipped.

For saving modified Step Function there will be required three(!) times to hit save.

  • in visual editor by clicking “Apply and exit”
  • in Step Fuunction Edit form by clicking “Save”
  • in popup confirmation by clicking “Save anyway”

After saving mission is achieved, there new execution session can by started. This time, there could be 3 possible flows like in following screenshots:

3 possible flows

Overall, with the new Workflow Studio release, it is getting simpler and quicker to deal with Step Functions as direct YAML modification might be tricky. Managed service learning curve is also getting simpler as the developer sees whole blocks pallets in the editor and can jungle with properties easily.

--

--

Yuri Fenyuk
Yuri Fenyuk

Written by Yuri Fenyuk

Experienced software developer

No responses yet