Implement a simple Restful API on Django using the following tech stack: Python, Django Rest Framework, AWS DynamoDB
git clone https://github.com/smdpro/serverless-django-rest.git
cd serverless-django-rest
- install python 3.11 from here
On Linux
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
run docker container for dynamodb
docker run -d -p 7000:8000 amazon/dynamodb-local
run local migration for creating the table
python local_maigration.py
After this, updating .env file.
IS_OFFLINE=True
REGIN_NAME=localhost
ENDPOINT_URL=http://localhost:7000
Run server
python manage.py runserver
-
Download AWS Cli from here and install it.
-
on aws cli terminal:
aws configure
- Enter your IAM informations:
$ AWS Access Key ID [None]: ENTER YOUR ACCESSKEY
$ AWS Secret Access Key [None]: ENTER YOUR SECRETKEY
$ Default region name [None]: ENTER YOUR REGION
$ Default output format [None]: json
- install serverless:
npm install -g serverless
- install serverless packages from package.json
npm install
- deploy your Django project to AWS Lambda using Serverless
serverless deploy