testdrivenio / fastapi-elastic-beanstalk

FastAPI on AWS Elastic Beanstalk

Home Page:https://testdriven.io/blog/fastapi-elastic-beanstalk/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deploying a FastAPI 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 fastapi-songs-postgres -p 5432:5432 \
    -e POSTGRES_USER=fastapi-songs -e POSTGRES_PASSWORD=complexpassword123 \
    -e POSTGRES_DB=fastapi-songs -d postgres
  5. Initialize the database:

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

    (venv)$ uvicorn main:app --reload
  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 fastapi-songs-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

About

FastAPI on AWS Elastic Beanstalk

https://testdriven.io/blog/fastapi-elastic-beanstalk/


Languages

Language:Python 96.8%Language:Procfile 3.2%