Introduction to AWS Step Function

Step Function is state-machine based workflow coordination as a service provided by AWS. AWS provides a straightforward way for application developers to create an execution workflow to coordinate the use of multiple AWS Lambda or Amazon Elastic Compute Cloud (EC2) components in distributed applications running on the cloud.

Before digging into AWS Step function, let’s take an example.

You want to send an automated verification message to the new user registered on your portal and the waiting/grace period for this verification is 30 minutes. If the user doesn’t verify account in 30 minutes you will delete his/her data from your database or if user verified his/her account then you send him/her a welcome message.
Screenshot from 2018-03-26 16-52-54

ASL (Amazon State Language) JSON Based Code for above State Machine can be found here.

I think this is nothing more than a state machine. It has a start state and end state. We can do all this task by AWS Step Function. We can use AWS Lambda for business logic. To know more about AWS Lambda, you can refer this blog:  A WalkThrough with AWS Lambda.

To understand AWS Step Functions, you will need to be familiar with a number of important concepts.

States are elements in the state machine. A state is referred to by its name, which can be any string, but which must be unique within the scope of the entire state machine. They have many types like task, choice, pass, fail, success, wait or parallel. (That will be explained in an upcoming blog.)

All the business logic of your application is written in the task. Amazon States Language represents tasks by setting a state’s type to task and by providing the ARN of the activity or Lambda function.

When the state machine is executed, we have to provide the next field in our JSON to determine the next state to go. It repeats unit it reaches the states of type Success, fail or End or some exception while execution.

State Machine Data
State machine takes the following forms of data i.e. input data to the state machine, data exchange between the state machine and output of the state machine. It is represented in JSON format.

{ “multiply”: [5, 6] }

Error Handling
An error can occur anytime while execution of state machine.  State machine causes the execution to fail entirely. Step Functions represents errors in ASL using some predefined error names. ASL defines a set of built-in strings of some well-known errors, all beginning with the States prefix.

This will be all for the blog post. In my upcoming blogs I will be talking more about Creating State Machine using different services provided by AWS and triggering your state machine using AWS SDK.

Thanks for reading!


Written by 

Aakash Jain is a software consultant having more than 1 year of experience. Aakash likes to explore new technologies. He loves online gaming, watching marvels movies, playing badminton and exploring new places. Aakash is familiar with programming languages such as Angular 4, Java, Scala, C++, TypeScript, HTML and CSS.

2 thoughts on “Introduction to AWS Step Function

Leave a Reply

%d bloggers like this: