Giter Club home page Giter Club logo

terraform-ecs-fargate-nlb's Introduction

Terraform ECS Fargate NLB

A set of Terraform templates used for provisioning network application stacks on AWS ECS Fargate using an NLB (network load balancer) rather than ALB.

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
nlb.tf NLB, Target Group, Listener
nsg.tf NSG for NLB and Task
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

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

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"
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 -t [email protected]:turnerlabs/terraform-ecs-fargate-nlb

Additional Information

terraform-ecs-fargate-nlb's People

Contributors

jritsema avatar yzhanggithub avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-ecs-fargate-nlb's Issues

curl -s your_website.io can not be trusted.

Hello there,

using curl -s get-fargate-create.turnerlabs.io | sh forces the user to trust an unknown server. If this is hijacked, all of the users who use this website are in danger of being compromised.

Instead, I suggest to store the sh file on your GitHub repository and use it to curl. For example, Oh My Zsh uses:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

This way, users will use script from a lot more trusted server.

Node 10 Lambda phase 1 support ends by July 30, 2021

There is a Node 10 lambda in the repo. It may cause issue to create (or update later) when Node 10 Lambda support ends in AWS.
Workaround if not updated in the release:
In env/dev/ecs-event-stream.tf, change the runtime to either value - "nodejs12.x" or "nodejs14.x"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.