This web app is a very basic clone of the original website of Landon Hotel. It is build using React and AWS Amplify. It also demonstrate a basic example of Serverless React Web App.
- React js
- AWS Amplify
- DynamoDB
- Amazon API Gateway
- Lambda Functions
- AWS Account (Preferably free tier).
- Node js (v18.x and above)
- aws-cli for Amplify builds
Local Server
To run the app locally :-
- Clone this repo
- Install dependencies using
yarn
- Uncomment the
.json
file imports on the components. - Comment out the hooks (
useState
anduseEffect
) call parts on the same. - Run the app using
yarn dev
AWS Amplify build
- Install and configure aws-cli (preferably v2).
- Its better to use us-east-1 as the region, otherwise it is neccessary to change the region in DynamoDB table creation codes, which are available under
src/scripts
. - Create the tables using
yarn table
- Load Data into tables using
yarn loaddata
- Create, Deploy and Test Lambda fuctions to read data from DynamoDB. Total four functions needed to read data from four tables. Sample Code :-
import { DynamoDB } from "@aws-sdk/client-dynamodb"; import { DynamoDBDocument } from "@aws-sdk/lib-dynamodb"; const REGION = "us-east-1"; const dbclient = new DynamoDB({ region: REGION }); const ddbDocClient = DynamoDBDocument.from(dbclient); export const handler = async (event) => { try { const params = { TableName: "GalleryImages", }; const data = await ddbDocClient.scan(params); return data.Items; } catch (error) { console.error(error); } };
- Create four API Gateway Routes (GET) and Integrate the lambda functions.
- It is better to use a seperate stage in the API Gateway for the API requests rather than
default
. - The base API Url is saved as environment variable with key name
VITE_BASE_URL
. Same can be added to the AWS Amplify. - Once the code is committed follow the deployment steps in the AWS Amplify console.
- Once the Deployment is ready it can be accessed with the generated app url https://<branch name>.<random string>.amplifyapp.com .