All Projects → turnerlabs → Terraform Ecs Fargate

turnerlabs / Terraform Ecs Fargate

Licence: apache-2.0
A Terraform template used for provisioning web application stacks on AWS ECS Fargate

Projects that are alternatives of or similar to Terraform Ecs Fargate

Karch
A Terraform module to create and maintain Kubernetes clusters on AWS easily, relying entirely on kops
Stars: ✭ 38 (-87.03%)
Mutual labels:  aws, terraform, hcl, containers
Terraform Aws Ecs Fargate
Terraform module which creates ECS Fargate resources on AWS.
Stars: ✭ 35 (-88.05%)
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 (+77.47%)
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 (-70.99%)
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 (-25.94%)
Mutual labels:  aws, ecs, terraform, hcl
Terraform Aws Alb
Terraform module to provision a standard ALB for HTTP/HTTP traffic
Stars: ✭ 53 (-81.91%)
Mutual labels:  aws, ecs, terraform, hcl
Terraform Fargate Example
Example repository to run an ECS cluster on Fargate
Stars: ✭ 206 (-29.69%)
Mutual labels:  aws, ecs, terraform, hcl
Terraform Ecs Autoscale Alb
ECS cluster with instance and service autoscaling configured and running behind an ALB with path based routing set up
Stars: ✭ 60 (-79.52%)
Mutual labels:  aws, ecs, terraform, hcl
Terraform Aws Ecs Codepipeline
Terraform Module for CI/CD with AWS Code Pipeline and Code Build for ECS https://cloudposse.com/
Stars: ✭ 85 (-70.99%)
Mutual labels:  aws, ecs, terraform, hcl
Aws Ecs Airflow
Run Airflow in AWS ECS(Elastic Container Service) using Fargate tasks
Stars: ✭ 107 (-63.48%)
Mutual labels:  aws, ecs, terraform, hcl
Kubenow
Deploy Kubernetes. Now!
Stars: ✭ 285 (-2.73%)
Mutual labels:  aws, terraform, hcl
Multiregion Terraform
Example multi-region AWS Terraform application
Stars: ✭ 149 (-49.15%)
Mutual labels:  aws, terraform, hcl
Terraform Aws Labs
Terraform template for AWS provider ☁️
Stars: ✭ 146 (-50.17%)
Mutual labels:  aws, terraform, hcl
Ladder
A general purpose extensible autoscaler for the cloud
Stars: ✭ 143 (-51.19%)
Mutual labels:  aws, ecs, containers
Aws Labs
step by step guide for aws mini labs. Currently maintained on : https://github.com/Cloud-Yeti/aws-labs Youtube playlist for labs:
Stars: ✭ 153 (-47.78%)
Mutual labels:  aws, terraform, hcl
Terraform Aws Eks
Terraform module to create an Elastic Kubernetes (EKS) cluster and associated worker instances on AWS
Stars: ✭ 2,464 (+740.96%)
Mutual labels:  aws, terraform, hcl
Terraform Aws Cloudfront S3 Cdn
Terraform module to easily provision CloudFront CDN backed by an S3 origin
Stars: ✭ 162 (-44.71%)
Mutual labels:  aws, terraform, hcl
Terraform Aws Ecs
Terraform module which creates AWS ECS resources
Stars: ✭ 203 (-30.72%)
Mutual labels:  aws, ecs, hcl
Kubify
Terraform Template to Setup a Kubernetes Cluster on OpenStack/AWS/Azure
Stars: ✭ 142 (-51.54%)
Mutual labels:  aws, terraform, hcl
Terraform Aws Components
Opinionated, self-contained Terraform root modules that each solve one, specific problem
Stars: ✭ 168 (-42.66%)
Mutual labels:  aws, terraform, hcl

Terraform ECS Fargate

A set of Terraform templates used for provisioning web application stacks on AWS ECS Fargate.

diagram

The templates are designed to be customized. The optional components can be removed by simply deleting the .tf file.

The templates are used for managing infrastructure concerns and, as such, the templates deploy a default backend docker image. We recommend using the fargate CLI for managing application concerns like deploying your actual application images and environment variables on top of this infrastructure. The fargate CLI can be used to deploy applications from your laptop or in CI/CD pipelines.

Components

base

These components are shared by all environments.

Name Description Optional
main.tf AWS provider, output
state.tf S3 bucket backend for storing Terraform remote state
ecr.tf ECR repository for application (all environments share)

env/dev

These components are for a specific environment. There should be a corresponding directory for each environment that is needed.

Name Description Optional
main.tf Terrform remote state, AWS provider, output
ecs.tf ECS Cluster, Service, Task Definition, ecsTaskExecutionRole, CloudWatch Log Group
lb.tf ALB, Target Group, S3 bucket for access logs
nsg.tf NSG for ALB and Task
lb-http.tf HTTP listener, NSG rule. Delete if HTTPS only Yes
lb-https.tf HTTPS listener, NSG rule. Delete if HTTP only Yes
dashboard.tf CloudWatch dashboard: CPU, memory, and HTTP-related metrics Yes
role.tf Application Role for container Yes
cicd.tf IAM user that can be used by CI/CD systems Yes
autoscale-perf.tf Performance-based auto scaling Yes
autoscale-time.tf Time-based auto scaling Yes
logs-logzio.tf Ship container logs to logz.io Yes
secretsmanager.tf Add a Secrets Manager secret with a CMK KMS key. Also gives app role and ECS task definition role access to read secrets from Secrets Manager Yes
secrets-sidecar.tf Adds a task definition configuration for deploying your app along with a sidecar container that writes your secrets manager secret to a file. Note that this is dependent upon opting in to secretsmanager.tf. Yes
ssm-parameters.tf Add a CMK KMS key for use with SSM Parameter Store. Also gives ECS task definition role access to read secrets from parameter store. Yes
ecs-event-stream.tf Add an ECS event log dashboard Yes

Usage

Typically, the base Terraform will only need to be run once, and then should only need changes very infrequently. After the base is built, each environment can be built.

# Move into the base directory
$ cd base

# Sets up Terraform to run
$ terraform init

# Executes the Terraform run
$ terraform apply

# Now, move into the dev environment
$ cd ../env/dev

# Sets up Terraform to run
$ terraform init

# Executes the Terraform run
$ terraform apply
Important (after initial terraform apply)

The generated base .tfstate is not stored in the remote state S3 bucket. Ensure the base .tfstate is checked into your infrastructure repo. The default Terraform .gitignore generated by GitHub will ignore all .tfstate files; you'll need to modify this!

fargate-create

Alternatively you can use the fargate-create CLI to scaffold new projects based on this template.

install

curl -s get-fargate-create.turnerlabs.io | sh

create an input vars file (terraform.tfvars)

# app/env to scaffold
app = "my-app"
environment = "dev"

internal = true
container_port = "8080"
replicas = "1"
health_check = "/health"
region = "us-east-1"
aws_profile = "default"
saml_role = "admin"
vpc = "vpc-123"
private_subnets = "subnet-123,subnet-456"
public_subnets = "subnet-789,subnet-012"
tags = {
  application   = "my-app"
  environment   = "dev"
  team          = "my-team"
  customer      = "my-customer"
  contact-email = "[email protected]"
}
$ fargate-create -f terraform.tfvars

Additional Information

Install pre-commit hook that checks terraform code for formatting

ln -s ../../pre-commit.sh .git/hooks/pre-commit
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].