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!


This entry was posted in Amazon, Amazon EC2, AWS, AWS Services and tagged , , . Bookmark the permalink.

2 Responses to Introduction to AWS Step Function

  1. Aakash Jain says:

    Reblogged this on Insane Lad.

  2. Very nice blog Aakash. This is for the people who like to invent and no better place to build than AWS. I would like to suggest people to join Amazon Web Services Training and help world to build the future of cloud computing.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s