A Microservice built to take customer details, using Aws Serverless offerings such as Lambda, API Gateway and DynamoDB. The microservice architecture can replicated and used anywhere where user contact and message needs to be taken.
The project has 4 main parts:
- Frontend: Contact Form
- API Gateway: to build an API
- Lambda Function: handles application logic
- DynamoDB: Database to store contact details
Client: HTML, CSS, Javascript
Server: API Gateway, Lambda (python), DynamoDB
Frontend
- The frontend is made with HTML, CSS AND Javascript.
- In script.js, the fetch api is used to make a post request API call to the api gateway.
- If the status code in the response is 200, the form filled successfully prompt pops up.
- If not then error is shown.
API Gateway
- Used the AWS API Gateway to create an API that would allow the frontend to communicate with the lambda function.
- A /contact resource was created and POST method was added. This was then integrated with the lambda function
Lambda
- The file lambda.py contains the code used for the function.
- The event recieved from the api is used by the event handler to extract the necessary data.
- A timestamp is used to give each item a unique key in the dynamodb table
- The aws sdk for python, boto3 i used to save the data in dynamodb using the 'put_item' function.
- The event handler returns a response witha status code, appropriate headers for CORS, and success message.
DynamoDB