AWS Step Functions overview

Theory



What are Step Functions?



From AWS Docs: Step Functions is a serverless orchestration service that lets you combine AWS Lambda functions and other AWS services to create business-critical applications. With the Step Functions graphical console, you see your application workflow as a series of event-driven steps. Step Functions is based on state machines and tasks. A state machine is a workflow. A task is a state in a workflow that is a unit of work that is being performed by another AWS service. Each step of the workflow is a state.



With the built-in Step Functions controls, you check the status of each workflow step to ensure that your application is running in the correct order and as expected. Depending on your use case, Step Functions can call AWS services such as Lambda to complete tasks. You can create workflows for processing and publishing machine learning models. You can use Step Functions to manage AWS services such as AWS Glue to create Extract, Transform, and Load (ETL) workflows. You can also create lengthy automated workflows for applications that require human interaction.



Or, in simple words, a service for managing your processes.





What are the possible use cases for Step Functions?



  1. Orchestration Lambda Functions



    image

  2. Branching



    image

  3. Exception handling (Retry or Catch)



    image

  4. Human participation in the process



    image

  5. Parallelism



    image



Process types in Step Functions



  • Standard - needed for processes running for a long time, has broad support for services and interaction options
  • Express - needed for fast-running processes (5 minutes), saving ~ 20 times per million executed processes. Has less integration with AWS services


Types of Integration with AWS Services



Request a response (default) - Calls the service and allows Step Functions to go to the next state after receiving the HTTP response.



Run a job (.sync) - calls the service and waits for the job to complete.



Wait for a callback with a task token (.waitForTaskToken) - calls the service with the task token and waits for the task token to return using the callback.



Comparison of Integration with AWS Services in Standard and Express Types



Supported Service Integrations for Standard

Service Request Response Run a Job (.sync) Wait for Callback (.waitForTaskToken)
Lambda βœ“ βœ“
AWS Batch βœ“ βœ“
DynamoDB βœ“
Amazon ECS / AWS Fargate βœ“ βœ“ βœ“
Amazon SNS βœ“ βœ“
Amazon SQS βœ“ βœ“
AWS Glue βœ“ βœ“
SageMaker βœ“ βœ“
Amazon EMR βœ“ βœ“
CodeBuild βœ“ βœ“
AWS Step Functions βœ“ βœ“ βœ“


Supported Service Integrations for Express

Service Request Response Run a Job (.sync) Wait for Callback (.waitForTaskToken)
Lambda βœ“
AWS Batch βœ“
DynamoDB βœ“
Amazon ECS / AWS Fargate βœ“
Amazon SNS βœ“
Amazon SQS βœ“
AWS Glue βœ“
SageMaker βœ“
Amazon EMR βœ“
CodeBuild βœ“
Step Functions βœ“ βœ“


Enough theory, let's go for example.



Theoretical example



In order to get at least some idea of ​​what the service looks like, consider the Hello world example.



Preconditions



  1. AWS account
  2. Go to Step Functions service in AWS account


So the following is what we do:



  1. Go to "Create Step Functions"
  2. Define state machine = Author with code snippets
  3. Type = Standard
  4. Definition =



    {
      "Comment": "A Hello World example of the Amazon States Language using Pass states",
      "StartAt": "Hello",
      "States": {
        "Hello": {
          "Type": "Pass",
          "Result": "Hello",
          "Next": "World"
        },
        "World": {
          "Type": "Pass",
          "Result": "World",
          "End": true
        }
      }
    }




Click Start execution. Insert can be omitted. You should see a diagram like this:



image

Congratulations, you've created the simplest Step Functions.



Instead of a conclusion



If this topic is interesting, in the next part we will create Step Functions with AWS Lambda + SQS + SNS integration, as shown in the diagram:



image



Links to sources:



https://docs.aws.amazon.com/step-functions/



All Articles