A fully serverless REST API for a Coffee Shop, built with AWS Lambda, API Gateway, and DynamoDB using the Serverless Framework. Supports full CRUD operations (Create, Read, Update, Delete) for menu items, with automated infrastructure and CI/CD via GitHub Actions.
- AWS API Gateway: RESTful endpoints
- AWS Lambda: Node.js/TypeScript handlers for each CRUD operation
- DynamoDB: Stores menu items
- Serverless Framework: Infrastructure as Code (IAC)
- CI/CD: GitHub Actions pipeline for multi-stage deployments (
dev,prod) - Unit/Integration Tests: Jest and aws-sdk-client-mock
- Business Case: Coffee Shop menu management
your-project/
├── src/handlers/ # Lambda handlers (CRUD)
│ ├── createItem.ts
│ ├── getItem.ts
│ ├── updateItem.ts
│ ├── deleteItem.ts
│ └── listItems.ts
├── tests/ # Unit/integration tests
│ ├── unit/
│ └── integration/
├── .github/workflows/ # GitHub Actions CI/CD
│ └── deploy.yml
├── serverless.yml # Serverless config (IAC)
├── package.json
├── tsconfig.json
├── README.md
└── .gitignore
| Method | Path | Description |
|---|---|---|
| POST | /items | Create item |
| GET | /items/{id} | Get item by ID |
| PUT | /items/{id} | Update item by ID |
| DELETE | /items/{id} | Delete item by ID |
| GET | /items | List all items |
- Clone the repository
- Install dependencies
npm install
- Configure AWS credentials (via
aws configureor environment variables) - Deploy to AWS
npx serverless deploy --stage dev # or for production npx serverless deploy --stage prod
- Located at
.github/workflows/deploy.yml - Triggers on push to
mainormaster - Installs dependencies, configures AWS, and deploys using Serverless Framework
- Supports multi-stage deployments (e.g.,
devfor feature branches,prodfor main) - Add your AWS credentials as GitHub secrets:
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY
- Unit tests:
npm test - Integration tests: Place in
tests/integration/ - Uses
aws-sdk-client-mockfor mocking DynamoDB in tests
This API is designed for a Coffee Shop to manage its menu items (e.g., add new drinks, update prices, remove items, and list the menu).
- Include screenshots of the GitHub Actions pipeline and AWS Console in this section.
- Record a Loom video walkthrough of the code, infrastructure, and CI/CD pipeline.
MIT
Add a step in your GitHub Actions workflow to install the latest Serverless Framework globally before running deploy:
- name: Install Serverless Framework
run: npm install -g serverlessPlace this step before the npx serverless deploy step.
Add Serverless Framework to your project’s package.json:
npm install --save-dev serverlessThen, in your workflow, use:
- name: Deploy with Serverless
run: npx serverless deploy --stage prodThis ensure the correct version is always available.
- If you have a
package.jsonwith aserverlessversion, make sure it matches what you want (v4 is the latest). - If you want to use v3, specify it explicitly:
npm install --save-dev serverless@3
Example workflow snippet:
- name: Install dependencies
run: npm ci
- name: Install Serverless Framework
run: npm install -g serverless
- name: Deploy with Serverless
run: npx serverless deploy --stage prodOr, if you add it as a dev dependency:
- name: Install dependencies
run: npm ci
- name: Deploy with Serverless
run: npx serverless deploy --stage prodChoose one of the above solutions and re-run your workflow.
If you want to use a specific version, install it explicitly. If you want the latest, just install globally or as a dev dependency.
Run this in your project root:
npm install --save-dev serverless-offlineIf you do not need local emulation (i.e., you don’t use serverless offline), you can remove serverless-offline from the plugins: section in your serverless.yml.
- If you want to use serverless-offline:
Install it as shown above. - If you do NOT need it:
Remove it from yourserverless.ymlunder theplugins:section.
After making the change, commit and push. Your CI/CD should then work without this error.