This is a foundational structure designed to create a scalable and high-performance API using Amazon Web Services (AWS) technologies. The API development will be facilitated through Chalice, an open-source AWS framework that simplifies the process of building serverless APIs.
A serverless computing service that runs your code without requiring you to provision or manage servers. AWS Lambda will handle the functionality of the API.
A Python framework developed by AWS. Chalice facilitates the creation of serverless APIs and microservices, simplifying tasks such as route definition, request and response handling, and integration with other AWS services.
A highly scalable, high-performance NoSQL database service provided by AWS. DynamoDB will serve as the storage layer to maintain the API data.
A comprehensive service that enables API operations such as creation, deployment, management, security, and monitoring. The API Gateway will serve as the entry point for the API, managing client requests and routing them to the correct Lambda functions.
To secure our API, we will incorporate JSON Web Tokens (JWT) as our means of authentication. JWT is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed.
A Pythonic interface to DynamoDB that allows for easy interaction with DynamoDB databases. It simplifies CRUD operations and also supports advanced DynamoDB features.
An open-source technology used for creating, shipping, and running applications. Docker will enable us to package the API and its dependencies, ensuring consistent and error-free deployment.
The main goal of this project is to create a scalable, serverless API foundation using modern AWS technologies and best practices. The use of JWT for authentication adds an additional layer of security for the API. This project can serve as a blueprint for developing various types of APIs, from RESTful APIs to APIs for integration with different systems and services.
This model project acts as a boilerplate for API development that capitalizes on the myriad of resources AWS has to offer. It allows for the development of high availability and robust solutions, enabling developers to focus on crafting innovative applications rather than worry about infrastructure management.
- Docker (to run amazon/dynamodb-local)
- Python 3.10
- Packages listed in
requirements.txt
- Postman (For API testing)
-
Install the necessary packages.
- If you have pip:
pip install -r requirements.txt
- If you have pipenv:
pipenv install
-
Run a local DynamoDB.
- Set the env variable
DB_HOST
tohttp://localhost:8000
- Set the env variable
-
Create a config and start chalice.
- Create a config:
make config
- Start chalice:
make run make chalice
Now you should be able to test the API on http://localhost:8010
or run the tests:
To test the API using Postman, follow these steps:
1 - Open Postman.
2 - Click on File > Import....
3 - Select the Chalice.postman_collection.json file from your local directory.
4 - Once the collection is imported, you will see all the endpoints loaded into Postman.
5 - Now you can select any endpoint and click "Send" to run the test.
To stop and cleanup:
make clean
Note: This requires that you have setup the credentials for AWS
DEV
chalice deploy --stage dev
PROD
chalice deploy --stage prod