This is an example repository showing how to use Terraform to bootstrap an AWS account and deploy a simple ECS Fargate cluster. I originally wrote this for an interview a while ago and decided to open source it. While I feel this code is good, I wrote this in under 4 hours, so there's definitley room for improvement. Feel free to open issues and/or contribute.
After following all of the instructions in the iac/README.md, you will have a working ECS Fargate cluster with a small Python server that provides a simple API that will return the Fibonnaci servies for the passed number. See test.http for examples. There is also a /health endpoint.
A pre-commit configuration is provided as well as an included Github action to build and run tests when a pull request is created.
After completing all of the steps outlined in each of the README files, the following AWS resources will be created:
- VPC
- Public and Private VPC Subnets
- NAT Gateway
- ECR Repository
- S3 Bucket
- KMS Key
- Dynamodb table
- ECR Fargate Cluster
- ALB
- Security Groups
- IAM Policies and Roles
brew install pre-commit
or follow pre-commit installation instructionspre-commit install
See iac/README.md.
Simply use curl against the load balancer created by the IaC code above.
curl -i http://<load balancer dns>:8000/?n=10
Requires:
- Python 3.12
- PDM
While in the project root directory:
# Install pdm
pipx install pdm
# Install dependencies, including dev dependenceis
pdm install -d
To run the server, simply run pdm start
This project uses the GNU GPLv3 license.