ECS cluster with instance and service autoscaling configured and running behind an ALB with path based routing set up
MIT License
Amazon EC2 Container Service (ECS) is a highly scalable, fast, container management service that makes it easy to run, stop, and manage Docker containers on a cluster of EC2 instances (called container instances).
The idea behind ECS is to create a cluster (a group of container instances managed by ECS), define what Docker containers we want to run (with configuration for each container) and ECS will take care of deploying those containers across the cluster, rolling out new versions and integrating with other AWS infrastructure/services.
A task definition is required to run a Docker container on an ECS cluster. A task definition specifies various parameters such as which Docker image(s) to use and the repository in which the image is stored, how much CPU and memory to use for the container, which environment variables should be passed to the container when it starts, which logging driver to use (awslogs, syslog etc.).
This repo contains Terraform configuration for an ECS cluster running three services (alpha, beta and charlie) with instance and service autoscaling configured at 80% CPU and memory (min and max autoscaling limits can be configured). The three services are sitting behind an Application Load Balancer (ALB) with path based routing set up.
As far as I could tell the ALB doesn't currently support URL Rewriting so I've had to manually perform this at the application level.
The code for the demo API is in the /demo-api directory and is built and hosted on Docker Hub.
Deployment to AWS is automated via Bitbucket Pipelines.
Before running pipeline for the first time you must:
Refer to deploy.bash files for manual deployment steps.