Skip to content

testdrivenio/flask-elastic-beanstalk

Repository files navigation

Deploying a Flask Application to 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 flask-movies-postgres -p 5432:5432 \
    -e POSTGRES_USER=flask-movies -e POSTGRES_PASSWORD=complexpassword123 \
    -e POSTGRES_DB=flask-movies -d postgres
  5. Initialize the database:

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

    (venv)$ flask run
  7. Navigate to http://localhost:5000/ 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 flask-movies-env
  4. Configure AWS RDS and Certificate Manager

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

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

    $ eb open