Books Serverless App is a serverless application built with AWS services. It leverages services such as S3, CloudFront, Lambda@Edge, Cognito, SSM Parameter Store, API Gateway, Lambda, and DynamoDB to provide a comprehensive serverless solution. The infrastructure is managed as code using AWS CDK.
This project is organized as a monorepo, with the frontend, backend, and infrastructure each located in their own directories.
The Infrastructure for the application is managed as code using AWS CDK. This allows for easy deployment and management of the AWS resources used in the application.
The Infrastructure code can be found in the packages/books-app-infra
directory.
The Frontend is an Angular application hosted in an S3 bucket. Content is distributed via CloudFront. User authentication is managed by a Cognito user pool.
The Frontend code can be found in the packages/books-app-frontend
directory.
The Backend is composed of an API Gateway that routes requests to a Lambda function. This function handles the CRUD operations for the book application.
The Backend code can be found in the packages/books-app-backend
directory.
The CRUD operations of the backend Lambda function are documented in Swagger. The Swagger files are hosted in another S3 bucket, which is also fronted with CloudFront. User authentication is managed by Cognito hostedUi and a Lambda@Edge function which intercepts the Cloudfront Viewer Request. The Cognito IDs required by the Lambda@Edge function are stored in the SSM Parameter Store .
The data for the application is stored in a DynamoDB table.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- You need to have Node.js and npm installed on your machine. You can download Node.js here and npm is included in the installation.
- Install Angular CLI globally:
npm install -g @angular/cli
- Install AWS CDK globally:
npm install -g aws-cdk
- AWS CLI configured with your credentials. You can follow this guide to set it up.
-
Clone the repository:
git clone https://github.com/GowsikChandran/Books-AWS-ServerlessApp-CDK.git
-
Navigate to the root directory of the project and install the dependencies:
cd BooksServerlessApp npm install
-
To build the frontend Angular application, navigate to the frontend directory and run:
cd packages/books-app-frontend ng build
-
To build the backend Lambda function, navigate to the backend directory and run:
cd packages/books-app-backend npx projen npx projen bundle-backend-lambda npx projen zip-backend-lambda
To deploy the infrastructure, navigate to the infrastructure directory and run:
cd packages/books-app-infra
npx projen
npx projen deploy
To destroy the infrastructure and clean up the resources, navigate to the infrastructure directory and run:
npx projen destroy