Get a new django app up and running in Elastic beanstalk in under 5 minutes
A starter template to get you up and running django app that works out of box with AWS Elastic Beanstalk.
The template contains following:
- Default settings for Project root, static root.
- Separate Development, Testing and Production settings for seamless deployment
- Celery fully configured to run in Elastic beanstalk app
- Automatic Db migrations when deploying.
Prerequisites
On your local machine, you should have following things configured as pre requisite:
- Postgres DB
- Rabbit MQ Broker
- AWS CLI installed and configured.
To complete prerequisites, refer this tutorial.
Steps
- In your project folder, clone contents of this repo with:
$ git clone [email protected]:CodePalTutorials/django-elasticbeanstalk-starter.git .
Clone contents inside this repo, hence [dot] at the end in the command above.
- Init python virtual environment and install required libs from requirements.
$ virtualenv venv
$ pip install -r requirements.txt
-
Add local database settings in
ebdjango/local_settings.py
. -
Create elastic beanstalk app and provision a postgres database with that app.
$ eb init -p python2.7 <appname>
$ eb init
$ eb create production-env
To provision database in Elastic beanstalk app, refer Step 6 of this tutorial.
- Set correct environment variables in Elastic beanstalk environment. For ex, to make current environment production environment, set:
$ eb setenv ENVIRONMENT=PROD
Options are PROD
, TEST
and DEVEL
.
-
Set your rabbit MQ broker URL in
ebdjango/testing_settings.py
&ebdjango/production_settings.py
. -
Deploy with
eb deploy
.
Refer to the tutorial below if you need more help with setting things up: https://www.trysudo.com/deploying-django-app-on-aws-using-elastic-beanstalk/) tutorial.
- Creating & Deploying basic Django app on Elastic Beanstalk: https://www.trysudo.com/deploying-django-app-on-aws-using-elastic-beanstalk.
- Adding celery on Django Elastic beanstalk app: https://www.trysudo.com/asynchronous-tasks-and-cron-jobs-in-aws-django-app-using-celery/
Any suggestions and contribution and welcome. Feel free to send PR, raise issues & make feature requests.