AWS recently expanded support for manipulating input and output data by adding 14 new intrinsic functions for AWS Step Functions to simplify data processing, reduce calls to downstream services, and write less code.
Step Functions is a low-code, visual workflow service from AWS to build distributed applications, automate IT and business processes, and orchestrate AWS services with minimal code. It currently supports integrations with over 220 AWS services, 10,000 API actions, and 18 intrinsic functions - initially, there were four intrinsic functions with States.Array, States.Format, States.JsonToString, and States.stringToJson. There are now 14 more, including Array, Unique Universal ID (UUID), Math, and string.
Amazon States Language (ASL) is a JSON-based, structured language that defines Step Functions workflows. Each state within a workflow receives a JSON input and passes a JSON output to the next state. The ASL provides a set of functions known as intrinsics that perform basic data transformations. Developers can apply intrinsics using ASL in task states within the ResultSelector field or in a Pass state in either the Parameters or Result field. Moreover, all intrinsic functions have the prefix "States." followed by a function.
UUID intrinsic for generating UUID:
"Type": "Pass",
"End": true,
"Result": {
"ticketId.$": "States.UUID()"
}
}
Earlier, when intrinsic functions were not available, the approach was different, as Jones Zachariah Noel, a developer advocate at FreshworksInc, explains in a dev.to blog post:
Without the intrinsic functions, the need for any such data processing or manipulation required you to write code in your AWS Lambda functions which involved having a dedicated Task in the State Machine where it would invoke your Lambda function. And your architectures would have excessive resources; your workflows mostly included AWS Step Functions invoking AWS Lambda functions for all data manipulations.
Yet now, with intrinsic functions, Benjamin Smith, a senior developer advocate for Serverless at AWS, explains in a blog post:
Intrinsic functions can allow you to reduce the use of other services, such as AWS Lambda or AWS Fargate, to perform basic data manipulation. This helps to reduce the amount of code and maintenance in your application. Intrinsics can also help reduce the cost of running your workflows by decreasing the number of states, number of transitions, and total workflow duration.
Similarly, Logic Apps, a competitive workflow service on Azure, offers expression functions. While executing a Logic App, some values can be set by functions provided by the Workflow Definition Language, a similar concept as with intrinsic functions in AWS Step Functions.
Dave Hall, an independent solution architected tweeted:
It's good to see Amazon investing in intrinsic functions. They're part of my new serverless strategy.
Lastly, AWS Step Functions’ new intrinsic functions are generally available in all regions where AWS Step Functions is available. Pricing details of the AWS Step Functions are available on the pricing page.