Exploring the new Intrinsic Functions in AWS Step Functions

Gowtham Shankar
2 min readMay 17, 2023

--

AWS Step Functions is a low-code, visual workflow service that developers use to build distributed applications, automate IT and business processes, and build data and machine learning pipelines using AWS services. Workflows manage failures, retries, parallelization, service integrations, and observability so developers can focus on higher-value business logic.

In the early days of Step Functions, every task needed to be a Lambda invocation. Over the years, AWS Step Functions has been evolved to the the principle of low-code model with the use of SDK Integration and several Service Integrations. AWS has taken this to another level by introducing the new Intrinsic functions also known as Intrinsics that help you perform basic data processing operations without using a Task state.

To simplify the different intrinsic functions offering, AWS has grouped the functions based on the type of data processing task that you want to perform.

Let’s take a look at some of the functions below.

States.Array

This function takes the input argument and converts the input argument into an array

{"Id": 123456}

"BuildId.$": "States.Array($.Id)"

The above function will return the following output

“BuildId”: [123456]

states.ArrayPartition

This function takes 2 input arguments — an array and a numerical value. The input array will be partitioned into multiple chunks with each chunk being the size of the numerical value passed in.

{"input":[1,2,3,4,5,6,7,8,9]} #input passed to the state machine

"inputArray.$": "States.ArrayPartition($.inputArray,4)"

The above function will return the following output

{"inputArray": [ [1,2,3,4], [5,6,7,8], [9]] }

Need to convert Json to String (or) String to Json ?

This can be achieved using JsonToString and StringToJson functions respectively as shown below.

{ "escapedJsonString": "{\"foo\": \"bar\"}" }

States.StringToJson($.escapedJsonString)

The above function will return the following output

{ "foo": "bar" }

Encoding and Decoding ?

You can now encode and decode string to base64 and vice versa.

{"input": "Data to encode" }

"base64.$": "States.Base64Encode($.input)"

The above function will return the following output

{"base64": "RGF0YSB0byBlbmNvZGU=" }

Can I nest Intrinsic Functions ?

Yes, You can nest up to 10 intrinsic functions within a field in your workflows.

Please note that this is not a comprehensive list of all functions step functions provide. For list of all intrinsic functions, Please follow the official documentation here.

Conclusion

Intrinsic functions can really help perform Mathematical calculation, Hash generation, encoding/decoding, data conversion between json and string, Array operations etc rather than using Lambda functions. However they are not as comprehensive as I want it to be. There are still some mundane operations that requires us to use Lambda functions in StepFunctions.

--

--

Gowtham Shankar

DevOps Engineer at AWS. Previously at VMware. Thoughts are my own.