REST API developed entirely in Python and based on AWS cloud services. Uses AWS Lambda to run your application code without managing servers, Amazon API Gateway to expose the API over HTTP, Amazon DynamoDB to store and manage application data, and Amazon CloudWatch to monitor and debug performance and application functionality. Serverless architecture allows developers to focus on application development rather than infrastructure management, resulting in reduced costs, greater scalability, and faster deployment. Additionally, by using AWS cloud services, your application benefits from the security and reliability of a proven, high-performance platform.
-
Create a New IAM Role with the following polices:
- CloudWacthFullAcces (to access AWS CloudWatch)
- AmazonDynamoDBFullAccess (to manage DynamoDB tables and items).
-
Create a New Lambda Function with the following configuration:
- Author from scratch
- Runtime: Python
- Execution Role with the new IAM Role was created in step one.
- Memory 500MB
- Timeout 1 Min.
-
Create a New Data Base in Amazon DynamoDB with
Partition Key: productID -
Create a New REST API using Amazon API Gateway with the following configurations:
- Endpoint Type: Regional
- Resources (all with enabled API Gateway CORS and Integrated with Lambda Function was created in step two) with the following methods:
/health GET OPTIONS /product DELETE GET OPTIONS PATCH POST /products GET OPTIONS -
Replace the code in your lambda function with the content of lambda_function.py file.
-
Create a new file named custom_encoder.py in your lambda function folder, copy & paste the code provided below into custom_encoder.py file
Note
If everything is working correctly, when accessing the API invocation URL, for example: https://mtp9f7cdta3.execute-api.us-east-1.amazonaws.com/your_stage_name/health returned with Status Code 200