Skip to content

albertsj1/terraform-aws-bootstrap-example

Repository files navigation

Example Terraform Account Bootstrap and Simple ECS Fargate Cluster

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.

Getting Started

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

Optional

Setup pre-commit

  1. brew install pre-commit or follow pre-commit installation instructions
  2. pre-commit install

AWS

See iac/README.md.

Testing

Simply use curl against the load balancer created by the IaC code above.

curl -i http://<load balancer dns>:8000/?n=10

Development

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

License

This project uses the GNU GPLv3 license.

About

A full working example for bootstrapping a new AWS account using Terraform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published