Create Scalable Business Workflows Using AWS Step Functions
In this blog post, we will look into how to create simple AWS Step Functions using a serverless framework.
Why I choose serverless?
Because it defines everything in a single file:
- IAM Role Statements
- Lambda Function Handlers
- Lambda Function Triggers
- Step Function States
- CloudFormation resources
Now, let us start building the step functions.
Step 1: Create the node-js template project using the following command
sls create - template aws-nodejs - path aws-sg-stepfunctions-demo
Step 2: Navigate to the folder aws-sg-stepfunctions-demo. serverless.yml is created inside the folder. If you invoke the sample hello function locally with the command below
sls invoke local -f hello
the following result is received.
{
"statusCode": 200,
"body": "{\n \"message\": \"Go Serverless v1.0! Your function executed successfully!\",\n \"input\": {}\n}"
}
Step 3: Refactor this lambda function by changing the message inside the body. I am going to create two more lambda functions and only the message component will be different in all these lambda functions.

Step 4: Create functions-definition.yml as below. We will refer this file in serverless.yml.

Step 4: Create stepfunctions-definition.yml as below. We will refer this file in serverless.yml as well.

Step 6: Create cloudwatch log group for the step function.

Step 5: Create serverless.yml with the following configuration

Now with all the configuration ready, deploy the step function using the below command.
sls deploy
This will create a state machine in Singapore region as below.

Source : https://github.com/pradheepap/aws-sg-stepfunctions-demo