Welcome! This a simple workflow to demonstrate how you can combine AWS Step Functions with AWS Lambda, Amazon DynamoDB, AWS XRay, using Microsoft .NET Core.
Along the way we provide an example of how to integrate Amazon API Gateway with AWS Step Functions, and use the AWS Step Function Service Integration Callback Pattern, to interface with an external website from a manual process in the workflow.
You will also see how we use the AWS Serverless Application Model (SAM) to define and model your Serverless application, and use AWS SAM CLI to build and deploy it.
To illustrate the use of AWS Step Functions I have created a scenario that describes a process where university students caught plagiarising on exams and/or assignments are required to take a test to assess their knowledge of the universities referencing standards.
Visually, the process looks like this:
The process starts by:
- Registering the plagiarism incident
- Scheduling an exam. Students have one week to complete the test.
- Send the student an email notification to inform them of the requirement
- The process waits for the student to complete the exam, then
- Determining whether or not the student has sat the exam, or passed
If the student has fails the exam they are allowed to resit the exam. Students get 3 attempts to pass the exam before the incident is either resolved, or administrative action is taken.
The architecture is relatively simple. There are two front end websites - one "Admin" website that capture the plagiarism incident; and a "Testing Centre" that tests the students knowledge of plagiarism.
The incident captured at via the Admin website initiates the AWS Step Function execution through an AWS Service integration on the /incident
resource for the POST
method.
Once the the exam is scheduled, we use an AWS Lambda service integration Task with a .waitForTaskToken
(see AWS docs). The Task Token is passed to the function which in turn generates the email which is sent to the student, notifying them of the exam requirements.
"SendNotification": {
"Type": "Task",
"Comment": "Send email confirming exam details and exam deadline. Wait for callback.",
"Resource": "arn:aws:states:::lambda:invoke.waitForTaskToken",
"Parameters":{
"FunctionName":"${SendExamNotificationFunction}",
"Payload":{
"input.$":"$",
"TaskToken.$":"$$.Task.Token"
}
},
"Next": "HasStudentPassedExam"
},
Once the student receives the email, the Task Token is passed to the Testing Centre. The student answers the questions and submits the results to the /exam
resource on the API. The Lambda integration processes the TaskToken and passes the results of the waiting execution to continue the workflow execution.
- AWS Step Functions
- AWS Step Functions Developer Guide
- Sample projects for Step Functions
- statelint
- Amazon States Language
- AWS Step Functions Examples on GitHub
- AWS Step Functions Supports 200 AWS Services To Enable Easier Workflow Automation blog post
- AWS Step Functions Workflow Studio – A Low-Code Visual Tool for Building State Machines blog post
- Serverless Application Model Developer Guide
- AWS::Serverless::StateMachine
- AWS Toolkit for Visual Studio Code
This sample code is made available under a modified MIT license. See the LICENSE file.