AWS Step Functions enables you to orchestrate serverless workflows by integrating with different AWS services. Those AWS services would need inputs in a specific format and also produces output in a specific format and to do that we have mapping templates / resolvers.
When working with different resolvers on Amazon States Language (ASL), you can have in-built methods called intrinsic functions. These intrinsic functions help with several operations in your mapping templates where you can process and manipulate with arrays, JSON objects, strings, math operations and more.
Previously, there were 4 intrinsic functions -
|Data encoding and decoding|
Now we have 18 intrinsic functions.
What it looked like without intrinsic functions
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 which is invoking AWS Lambda functions for all data manipulations.
When SDK integrations was announced, we started thinking about workflows that could easily integrate with other AWS services. Many of us thought of migrating our workflows in AWS Lambda to AWS Step Functions but there were a few challenges -
- We could use it only for direct SDK integrations without data processing and we could not eliminate Lambda functions completely.
- From the sustainability angle, we still had our Lambda code which was executing whenever our State Machine executes.
- The State Machines had additional Tasks, which affected the pricing as it's with every transition of state.
First set of intrinsic functions
Intrinsic functions helped us reduce some of the basic parsing use-cases executed in Lambda functions and were limited to -
- Format the message with variables.
- Parsing String to JSON and vice versa.
- Working with arrays either creating or retrieving the array.
What's possible now with intrinsic functions
With the 14 new intrinsic functions introduced, we have use-cases which are now possible within Step Functions without having additional Tasks. Some of the use-cases possible -
- Generating UUIDs when you are creating new records in your DynamoDB or messages which are posted to SQS queues or SNS topics.
- Able to hash string with different hashing algorithms -
SHA-256and more. Or even encoding and decoding string to
- Working with different array based manipulations, where you may have to get a specific item or a unique item in the array or partitioning your arrays.
- Easier way to split string into an array.
- Generating random numbers.
But when using intrinsic functions, you would have to consider the reserved characters which requires you to escape the characters with a backslash (
\). And the fields which support them which gives you a better understanding of which state what can be performed.