All Projects → jch254 → Terraform Ecs Autoscale Alb

jch254 / Terraform Ecs Autoscale Alb

Licence: mit
ECS cluster with instance and service autoscaling configured and running behind an ALB with path based routing set up

Projects that are alternatives of or similar to Terraform Ecs Autoscale Alb

Terraform Aws Ecs Fargate
Terraform module which creates ECS Fargate resources on AWS.
Stars: ✭ 35 (-41.67%)
Mutual labels:  aws, ecs, terraform, hcl
Terraform Aws Asg
Terraform AWS Auto Scaling Stack
Stars: ✭ 58 (-3.33%)
Mutual labels:  aws, terraform, hcl, autoscaling
Terraform Aws Ecs Codepipeline
Terraform Module for CI/CD with AWS Code Pipeline and Code Build for ECS https://cloudposse.com/
Stars: ✭ 85 (+41.67%)
Mutual labels:  aws, ecs, terraform, hcl
Ecs Pipeline
☁️ 🐳 ⚡️ 🚀 Create environment and deployment pipelines to ECS Fargate with CodePipeline, CodeBuild and Github using Terraform
Stars: ✭ 85 (+41.67%)
Mutual labels:  aws, ecs, terraform, hcl
Terraform Aws Ecs Container Definition
Terraform module to generate well-formed JSON documents (container definitions) that are passed to the aws_ecs_task_definition Terraform resource
Stars: ✭ 217 (+261.67%)
Mutual labels:  aws, ecs, terraform, hcl
Infrastructure As Code Talk
Sample code for the talk "Infrastructure-as-code: running microservices on AWS with Docker, ECS, and Terraform"
Stars: ✭ 520 (+766.67%)
Mutual labels:  aws, ecs, terraform, hcl
Terraform Aws Dynamodb
Terraform module that implements AWS DynamoDB with support for AutoScaling
Stars: ✭ 49 (-18.33%)
Mutual labels:  aws, terraform, hcl, autoscaling
Aws Ecs Airflow
Run Airflow in AWS ECS(Elastic Container Service) using Fargate tasks
Stars: ✭ 107 (+78.33%)
Mutual labels:  aws, ecs, terraform, hcl
Terraform Fargate Example
Example repository to run an ECS cluster on Fargate
Stars: ✭ 206 (+243.33%)
Mutual labels:  aws, ecs, terraform, hcl
Terraform Ecs Fargate
A Terraform template used for provisioning web application stacks on AWS ECS Fargate
Stars: ✭ 293 (+388.33%)
Mutual labels:  aws, ecs, terraform, hcl
Terraform Aws Alb
Terraform module to provision a standard ALB for HTTP/HTTP traffic
Stars: ✭ 53 (-11.67%)
Mutual labels:  aws, ecs, terraform, hcl
Cloudguardiaas
Check Point CloudGuard Network Security repository containing solution templates, Terraform templates, tools and scripts for deploying and configuring CloudGuard Network Security products.
Stars: ✭ 27 (-55%)
Mutual labels:  aws, terraform, hcl
Terra Aws Core Kube
Terraform configuration to bootstrap a Kubernetes Cluster on top of CoreOS using AWS-EC2 instances
Stars: ✭ 10 (-83.33%)
Mutual labels:  aws, terraform, hcl
Aws Scalable Big Blue Button Example
Demonstration of how to deploy a scalable video conference solution based on Big Blue Button
Stars: ✭ 29 (-51.67%)
Mutual labels:  aws, ecs, autoscaling
Lambda Deployment Example
Automated Lambda Deployments with Terraform & CodePipeline
Stars: ✭ 25 (-58.33%)
Mutual labels:  aws, terraform, hcl
Terraform Aws Cross Account Role
A Terraform module to create an IAM Role for Cross Account delegation.
Stars: ✭ 30 (-50%)
Mutual labels:  aws, terraform, hcl
Terraform Aws Github Ci
[DEPRECATED] Serverless CI for GitHub using AWS CodeBuild with PR and status support
Stars: ✭ 49 (-18.33%)
Mutual labels:  aws, terraform, hcl
Terraform Modules
Terraform Modules
Stars: ✭ 25 (-58.33%)
Mutual labels:  aws, terraform, hcl
Terraform Sqs Lambda Trigger Example
Example on how to create a AWS Lambda triggered by SQS in Terraform
Stars: ✭ 31 (-48.33%)
Mutual labels:  aws, terraform, hcl
Ebs bckup
Stars: ✭ 32 (-46.67%)
Mutual labels:  aws, terraform, hcl

Terraform-ecs-autoscale-alb

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.

Dockerhub badge

Base-infra components:

  • VPC
  • Public and private subnets
  • Internet Gateway
  • NAT Gateways
  • ALB in public subnet with Route53 record
  • ECS cluster
  • ECS container instances in private subnet with autoscaling configured (running Datadog agent and NGINX serving a default index.html for ALB default action on boot)
  • Bastion instance in public subnet (in ASG with a fixed size of one). This only allows SSH access for a specific IP address.

Service components

  • ECS service with autoscaling configured
  • ALB listener and target group

Deploying via Bitbucket Pipelines

Deployment to AWS is automated via Bitbucket Pipelines.

Before running pipeline for the first time you must:

  1. Enable Bitbucket Pipelines for repository
  2. Create an S3 bucket named 'your-terraform-remote-state' for Terraform remote state via console or CLI
  3. Create a Bitbucket Pipelines IAM user with the required permissions
  4. Set up the following account-level Bitbucket Pipelines environment variables in Bitbucket UI:
    • AWS_ACCESS_KEY_ID = PIPELINES_USER_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY = PIPELINES_USER_SECRET_ACCESS_KEY
  5. Set up the following repository-level Bitbucket Pipelines environment variables in Bitbucket UI:
    • TF_VAR_ssh_allowed_ip = YOUR_IP
    • TF_VAR_acm_arn = YOUR_ACM_CERT_ARN
    • TF_VAR_route53_zone_id = YOUR_R53_ZONE_ID
    • TF_VAR_datadog_api_key = YOUR_DATADOG_API_KEY
    • TF_VAR_key_pair_name = YOUR_KEY_PAIR_NAME
    • TF_VAR_bastion_key_pair_name = YOUR_KEY_PAIR_NAME
  6. Edit configuration in the .tfvars file in /base-infra, /alpha-service, /beta-service and /charlie-service directories with required values.
  7. Update deploy.bash file in /base-infra, /alpha-service, /beta-service and [/charlie-service] (../master/charlie-service/) directories with your remote state bucket name.
  8. Uncomment steps in /bitbucket-pipelines.yml and commit to repository to trigger the pipeline

Refer to deploy.bash files for manual deployment steps.

  • TODO: Add comments throughout infra code
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].