Geek Culture
Published in

Geek Culture

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.

aws lambda nodejs

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

functions-definition.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

serverless.yml

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.

State Machine

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

--

--

--

A new tech publication by Start it up (https://medium.com/swlh).

Recommended from Medium

Introducing Feature Plans

Public Cloud Inter-region Network Latency as Heat-maps

Tutorial on Using Gitlab CI/CD Pipelines to Deploy Your Python Flask Restful API With Postgres on…

4 Ways To Make Extra Income As A Software Developer

Automating Workflows with GitHub Actions

Is Software Development Right For You?

Rails, Webpacker, and Vue CLI Can Actually Play Nicely

cybernetic meadows: how a bot helps engineers at the FT

A road roller crushing empty cans at the indietracks festival.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pradheepa P

Pradheepa P

Backend Engineer, Cloud Practitioner

More from Medium

AWS AppSync GraphQL APIs to invoke Lambda function

Simple Steps For DynamoDB Cost Optimization

Serverless Framework + AWS: automatically creating certificate and domain for your app

What is Serverless and how to go serverless?