Serverless workflows in AWS

Serverless workflows in AWS

Sage Huynh

Before we start figuring the Workflows in AWS. I would like to introduce you a quick section about AWS step functions.

AWS Step Functions is a visual workflow service that helps developers use AWS services to build distributed applications, automate processes, orchestrate microservices, and create data and machine learning (ML) pipelines.

Step functions are defined in JSON format using AWS States Language (ASL). The state machine can be validated and visualised as a workflow on AWS Console by providing the JSON definition.

Steps to create a step function

  1. First step: Create an IAM Role, this will let Lambda function write down logs to Cloudwatch

Go to AWS IAM -> Create Role -> AWS Service -> Choose Lambda -> "Next: Permissions" -> filter then select the policy "CloudWatchLogsFullAccess" -> "Next: Tags" -> "Next: Review" -> Provide the role name as "lambda_cloudwatch_access" -> Create Role.

  1. Second step: Create a Lambda Function from AWS Console

On AWS Management Console, go to "Lambda" service -> Create Function -> Choose "Author from scratch" -> Provide the function name as Hello with runtime as Python 3.6 > Click on Choose or create an execution role under "Permissions" and select
"Choose an existing role" from the drop-down and provide the role name lambda_cloudwatch_access > Click on Create function button.

You can take this example for Lambda handler. (Note that no need to use Python)

def lambda_test_handler (event, context):
name = event['tester']
return 'Hello ' + name

Then simply click on Save button and also you should notice the ARN of lambda which will be used inside the step function.


  1. Third Step: Create the IAM role to grant access to Step Function to execute Lambda function

On AWS Console select IAM -> Create Role -> AWS Service -> Choose Step Function -> Click on "Next: Permissions" button ->
"AWSLambdaFullAccess" permission is displayed by default -> Next: Tags -> Next: Review -> Provide the role name as "stepfunction_lambda_access" -> Click on Create Role

  1. Forth Step: Create an AWS Step Function

After fill in the state machine definition, click "Next" and "Choose an existing IAM role" and provide the ARN of the role we created to grant lambda execution access to Step Function. Then click on Create state machine button.

So now, What is Workflows

A workflow is the order of steps, tasks, events, or interactions involved in the process of performing a certain task. Instead of displaying the application logic with complex code, you can use a workflow to visualise models and clearly control the logic in an application.

Step Functions is an AWS service that enables creation and management of. This service communicates with many other AWS services to build an application.

In AWS, there are many ways to manage a workflow definition. If you use an AWS console to create the definition workflow, it will be difficult and time-consuming to move the definition to another environment. Instead of creating a definition in an AWS console, you can build an environment in a few seconds using a severless framework. This method allows you to manage everything from coding to deployment in one place, saving you time and simplifying the process.

An example workflow where we are going to get Movie title feeds in CSV files uploaded them to S3.

That's it, thank you for reading!