Over a million developers have joined DZone.

Introduction to AWS Step Functions: (Part 1)

DZone's Guide to

Introduction to AWS Step Functions: (Part 1)

In this first post of the series, we get familiar with some terms of AWS Step Functions and begin laying down an example scenario.

· Cloud Zone ·
Free Resource

Learn how to migrate and modernize stateless applications and run them in a Kubernetes cluster.

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 waiting for 30 min for verification. If the user doesn't verify then account in 30 minutes, you will delete his data from your database, or if user verified his account then you send him a welcome message.
Screenshot from 2018-03-26 16-52-54

ASL JSON Based Code above State Machine can be found here.

I think this is nothing more than a state machine. It has both a start state and end state. We can do all these task using AWS Step Function. We can use AWS Lambda for business logic. To learn 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 so 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 executing a 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 this blog. In my upcoming blogs, I will be talking more about in Creating a State Machine using different services provided by AWS, triggering your state machine using AWS SDK, and more.

Thanks for reading!

Join us in exploring application and infrastructure changes required for running scalable, observable, and portable apps on Kubernetes.

amazon aws ,serverless architecture ,aws lambda ,aws tools ,cloud ,aws step functions ,state machine

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}