sfn-wait-for-callback

Welcome to the sfn-wait-for-callback repository! This project complements our blog post, demonstrating a real-world application of AWS Step Functions using the callback pattern.

We implement a basic UI that starts a Step Function, let's it wait for a specific input (title forbidden), and continues it only on user input.

Step Function Workflow

Deploy

You can use any package manager, we've used pnpm. Follow these commands to deploy the project to your AWS default profile:

pnpm install
pnpm run deploy:prod

Running Locally

To run the project on your local machine:

  1. Install dependencies:
pnpm install
  1. Start the development server:
pnpm run dev
  1. For the frontend, navigate to the packages/frontend directory and start its development server:
cd packages/frontend
pnpm run dev

Components

Frontend

Technology: Next.js

Submit Articles: We've implemented a mock form that submits new articles. We only send new article titles. If you send the title forbidden a step Function will halt.

Content Moderation System UI

Admin Page: In /admin we've built an admin page that shows you all waiting step functions. On approve or reject you will continue the Step Function with the respective decision.

image

More details are available in our blog post.

Backend Resources

  • Step Function: Built using AWS CDK, employing the chain syntax for state management.

    Step Function

  • Lambda Functions:

    • REST API: Starts Step Functions and retrieves items from DynamoDB.
    • Approval Receiver: Handles decision and task token reception.
    • Manual Approval Request: Records Step Functions awaiting approval in DynamoDB.
  • DynamoDB: Stores active Step Functions and related metadata.

Costs

This project is serverless, meaning it is 100% usage-based. Testing should be free under the AWS Free Tier. For larger-scale operations, be mindful of DynamoDB scan costs and Step Function state changes.

Contributions

Interested in contributing? Great! 🚀 Simply create an issue or a pull request, and we'll take a look.