Serverless Step Functions Plugin

3.29.1 · active · verified Sun Apr 19

The `serverless-step-functions` plugin provides deep integration for AWS Step Functions within the Serverless Framework. It allows developers to define, deploy, and manage complex serverless workflows directly within their `serverless.yml` configuration. As of version `3.29.1`, the project maintains a rapid release cadence, frequently pushing out new features and bug fixes, often several times per month. Key differentiators include automatic IAM role generation tailored to state machine definitions, comprehensive event source integrations (such as API Gateway, Scheduled events, and CloudWatch Events), support for advanced features like Blue-Green deployments, pre-deployment validation, CloudWatch Alarms, and X-Ray tracing. It significantly streamlines the orchestration of AWS services by abstracting away much of the underlying CloudFormation complexity required for Step Functions.

Common errors

Warnings

Install

Imports

Quickstart

This `serverless.yml` configuration demonstrates how to define a simple AWS Step Functions state machine with a basic `Wait` and `Succeed` state. It also shows how to trigger this workflow asynchronously via an AWS HTTP API endpoint, configuring the necessary API Gateway integration. This configuration should be placed in your `serverless.yml` file and deployed using `sls deploy`.

# serverless.yml
service: my-step-functions-service

frameworkVersion: '3'

plugins:
  - serverless-step-functions

provider:
  name: aws
  runtime: nodejs20.x # Or any supported runtime
  region: us-east-1
  stage: dev
  httpApi:
    cors: true

stepFunctions:
  stateMachines:
    mySimpleWorkflow:
      name: my-simple-workflow-${sls:stage}
      comment: "A basic workflow that waits and then succeeds"
      definition:
        Comment: "My Simple Workflow"
        StartAt: "WaitState"
        States:
          WaitState:
            Type: Wait
            Seconds: 5
            Next: "SucceedState"
          SucceedState:
            Type: Succeed
      events:
        - httpApi:
            path: /start-workflow
            method: post
            async: true
            response:
              headers:
                Content-Type: "'application/json'"
              template: "$input.json('$')"

view raw JSON →