Skip to content

CI / CD exercise for Python FastAPI on AWS with ECS Fargate + ALB

License

Notifications You must be signed in to change notification settings

gzog/fastapi-ecs-fargate

 
 

Repository files navigation

fastapi-ecs-fargate

CI / CD exercise for Python FastAPI on AWS with ECS Fargate + ALB

Usage

Repository contains:

  • application in Python (FastAPI),
  • docker image description (Dockerfile)
  • infrastructure as code for AWS

Get code of repo:

git clone git@github.com:jsporna/fastapi-ecs-fargate.git
cd fastapi-ecs-fargate

Python

Application is simple FastAPI Hello World code to show usage of docker in AWS. There is also dummy test for CI test job. Application can be run on localhost with virtual environment approach.

python3 -m venv venv
source venv/bin/activate
pip install -r dev-reqirements.txt

next

uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

or

make run

Docker

Application also can be run on localhost with docker

docker build -t fastapi-ecs-fargate .
docker run -p 8000:8000 fastapi-ecs-fargate

or

make docker-build
make docker-run

AWS

To build own AWS infrastructure you need:

First prepare configuration for aws-cli -> LINK When it is ready let's create some infrastructure in Cloud

cd iac
terraform init
terraform plan

In terminal will be printed a lot of new resources (33). Next let's apply it to AWS:

terraform apply

About

CI / CD exercise for Python FastAPI on AWS with ECS Fargate + ALB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HCL 81.4%
  • Python 7.9%
  • Makefile 4.3%
  • Smarty 3.7%
  • Dockerfile 2.7%