smdpro / serverless-django-rest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

serverless-django-rest

Implement a simple Restful API on Django using the following tech stack: Python, Django Rest Framework, AWS DynamoDB

1. Clone repository:

git clone https://github.com/smdpro/serverless-django-rest.git
cd serverless-django-rest

2. install requirements.txt

  • install python 3.11 from here

On Linux

python -m venv .venv 
source .venv/bin/activate
pip install -r requirements.txt

3. Run Locally

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

4. AWS Cli Configuration

  • 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

5. Deploy on AWS lambda

  • 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 

About

License:MIT License


Languages

Language:Python 100.0%