Skip to content

testdrivenio/django-elastic-beanstalk

Repository files navigation

Deploying Django to AWS Elastic Beanstalk

Check out the tutorial.

Want to use this project?

Local setup

  1. Fork/Clone

  2. Create and activate a virtual environment:

    $ python3 -m venv venv && source venv/bin/activate
  3. Install the requirements:

    (venv)$ pip install -r requirements.txt
  4. Spin-up a PostgreSQL container:

    (venv)$ docker run --name django-images-postgres -p 5432:5432 \
    -e POSTGRES_USER=django-images -e POSTGRES_PASSWORD=complexpassword123 \
    -e POSTGRES_DB=django-images -d postgres
  5. Apply the migrations:

    (venv)$ python manage.py migrate
  6. Run the server:

    (venv)$ python manage.py runserver
  7. Navigate to http://localhost:8000/ in your favorite web browser.

Elastic Beanstalk setup

  1. Install EB CLI.

  2. Initialize Elastic Beanstalk:

    $ eb init
  3. Create an Elastic Beanstalk environment:

    $ eb create django-images-env
  4. Obtain your EB CNAME by running eb status and add it to ALLOWED_HOSTS inside core/settings.py.

  5. Configure AWS RDS, S3, and Certificate Manager

  6. Commit all the changed files to git and deploy:

    $ git add .
    $ git commit -m "updates for eb"
    
    $ eb deploy
  7. Open the web application in your favorite web browser:

    $ eb open