AWS Step Functions lets you coordinate multiple AWS services into serverless workflows so you can build and update apps quickly. Using Step Functions, you can design and run workflows that stitch together services, such as AWS Lambda, AWS Fargate, and Amazon SageMaker, into feature-rich applications.
The application uses several AWS resources, including Step Functions state machines, Lambda functions and an EventBridge rule trigger. These resources are defined in the template.yaml
file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code.
The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda.
To use the SAM CLI, you need the following tools:
- SAM CLI - Install the SAM CLI
- Node.js - Install Node.js 16, including the NPM package management tool.
- Docker - Install Docker community edition
sam build
sam local invoke Queue
sam local invoke Approve
sam local invoke Failure
sam deploy --stack-name "test-step-function" --resolve-s3 --capabilities CAPABILITY_IAM
Build the Lambda functions with the sam build --use-container
command.
sam build
The SAM CLI installs dependencies defined in functions/*/package.json
, creates a deployment package, and saves it in the .aws-sam/build
folder.
sam logs -n Queue --stack-name [...] --tail
Tests are defined in the functions/*/tests
folder(s). Use NPM to install Mocha and run unit tests.
cd functions/queue && npm install && npm run test && cd -
cd functions/approve && npm install && npm run test && cd -
cd functions/failure && npm install && npm run test && cd -
sam delete --stack-name [...]