- No need to provision or manage the servers
- Horizontal Scalability
- Never pay for idle
- More reliable
Before deploying and running the project, ensure you have the following prerequisites:
- Node.js
- AWS account with proper permissions
- Serverless Framework CLI
- AWS CLI configured with valid credentials
- Clone the repository:
https://github.com/SomnathKar000/AWS-Serverless-API - Navigate to the project directory:
cd AWS-Serverless-API - Install the dependencies:
npm install - Set up your AWS credentials by configuring the AWS CLI:
Before deploying the project, you need to configure the following:
-
DynamoDB Table: Create a DynamoDB table in your AWS account and note down its name. Set the
DYNAMODB_TABLE_NAMEenvironment variable in theserverless.ymlfile with the table name. -
AWS Region: Set the desired AWS region in the
serverless.ymlfile using theregionproperty.
The Serverless Framework will package your code, create the necessary AWS resources, and deploy the API endpoints.
The CRUD API provides the following endpoints:
- Method: GET
- Description: Retrieves a list of all products.
- Method: GET
- Description: Retrieves information about a specific product.
- Path Parameter:
productId: The unique identifier of the product to retrieve.
-
Method: POST
-
Description: Creates a new product.
-
Request Body:
- Include the
productIdfield in the request body to create a new product. This is the only required field.
- Include the
-
Example Request Body:
{ "productId": "12345", "name": "Sample Product", "price": 19.99, "description": "A description of the product." }
This endpoint creates a new product with the provided details. The productId field must be unique, and it's a required field.
- Method: PATCH
- Description: Updates an existing product.
- Path Parameter:
productId: The unique identifier of the product to update.
- Request Body:
- Include product details in the request body to update the existing product.
- Method: DELETE
- Description: Deletes a specific product.
- Path Parameter:
productId: The unique identifier of the product to delete.
You can use tools like cURL or API testing clients (e.g., Postman) to interact with the API endpoints.
AWS API Gateway Base URL: https://ozkgj0har5.execute-api.ap-south-1.amazonaws.com/dev
Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.