Deploying the backend
The backend is a set of serverless microservices. In this section, shows you how to deply the application from a GitHub Repository:
- The Counting microservice - Uses an Amazon DynamoDB table for incrementing order numbers sequentially.
- The OrderManager microservice - Provides an API to send/update/cancel a coffee order. Consists of a DynamoDB table containing the state of each customer order.
- The Config microservice - Uses a DynamoDB table containing information about menu items and shop status, along with an Amazon API Gateway resource to provide authenticated access.
- The Publisher microservice - Routes events to different IoT core topics. IoT Core publishes event messages to front end applications.
- The QR Validator microservice - Provides QR codes to front end display application, Codes are sorted in a DynamoDB table and used to validate each order.
Cloning the GitHub repository
Clone the repo which will download a local copy of the instructions and code you will use to build the backend portion of the workshop.
- Run these commands in the Cloud9 terminal window:
git clone https://github.com/aws-samples/serverless-coffee-workshop ./serverlesspresso
- Within the Cloud9 file browser on the left hand side you can see the backend files have been downloaded.
Deploy the backend infrastructure
This is a good time to introduce the AWS Serverless Application Model, or AWS SAM. SAM is an open-source framework that makes it easier to deploy serverless infrastructure.
This allows you to specify your application requirements in code and SAM transforms and expands the SAM syntax into AWS CloudFormation to deploy your application. You will see and use SAM templates throughout this workshop.
More information on this services used in this section:
In this section, you will complete a SAM deployment which will build much of the backend infrastructure which we will add to throughout the rest of the workshop.
Go back to your browser tab with Cloud9 running. If you need to re-launch Cloud9, from the AWS Management Console, select Services then select Cloud9 under Developer Tools. Make sure your region is correct.
- Use the SAM CLI to build any code dependencies by running the following command:
- Use the SAM CLI to deploy the infrastructure by running the following command:
sam deploy --stack-name serverlesspresso-backend --resolve-s3 --capabilities CAPABILITY_IAM
- Once the deployment is complete, you’ll see a list of output in the terminal under
CloudFormation outputs from deployed stack.
Copy these outputs from the stack to a scratch file, notepad or text editor for later use. These are all the resource names you’ll need in subsequent modules.
- SAM has now used CloudFormation to deploy a stack of backend resources which will be used for the rest of the workshop.
- Multiple Lambda functions
- An S3 bucket
- A DynamoDB table
- A Cognito UserPool
- An AWS IoT thing
- Step Functions workflows
- EventBridge custom event bus
- Several IAM roles and policies
- You cloned a GitHub Repo containing an infrastructure template with resources used by the application.
- You deployed the core SAM template to your AWS account.
In the next module, you’ll learn about workflows and state machines, and build the main workflow that powers the application.
Now you are ready to start building 👷