fargate-create

command module
v0.2.0-pre-3-g32fb010 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2018 License: Apache-2.0 Imports: 1 Imported by: 0

README

fargate-create

A CLI tool for scaffolding out new AWS ECS/Fargate applications based on terraform-ecs-fargate and Fargate CLI.

Why?

The main design goal of this project is to create an easy and maintainable Fargate experience by separating infrastructure related concerns and application related concerns using tools that are optimized for each.

Installation

You can install the CLI with a curl utility script (macos/linux) or by downloading the binary from the releases page. Once installed you'll get the fargate-create command.

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

Assuming you have a project with a Dockerfile...

Specify your template's input parameters in terraform.tfvars (or terraform.json). The default web application template's input looks something like this.

region = "us-east-1"
aws_profile = "default"
app = "my-app"
environment = "dev"
internal = "true"
container_name = "app"
container_port = "8080"
lb_port = "80"
lb_protocol = "HTTP"
replicas = "1"
health_check = "/health"
health_check_interval = "10"
health_check_timeout = "5"
health_check_matcher = "200-299"
vpc = "xyz"
private_subnets = "xyz,abc"
public_subnets = "def,ghi"
saml_role = "devops"
tags = {
  app = "my-app"
  env = "dev"
}
$ fargate-create
scaffolding my-app dev
Looking up AWS Account ID using profile: default
downloading terraform template https://github.com/turnerlabs/terraform-ecs-fargate/archive/v0.2.0.zip
installing terraform template

done

Now you have all the files you need to spin up something in Fargate.

Infrastructure: provision using Terraform

cd iac/base
terraform init && terraform apply
cd ../env/dev
terraform init && terraform apply

Application: build/push using Docker and deploy using Fargate CLI

docker-compose build
login=$(aws ecr get-login --no-include-email) && eval "$login"
docker-compose push
fargate service deploy -f docker-compose.yml

To scaffold out additional environnments, simply change the environment input parameter in terraform.tfvars and re-run

$ fargate-create
scaffolding my-app prod
Looking up AWS Account ID using profile: default
downloading terraform template https://github.com/turnerlabs/terraform-ecs-fargate/archive/v0.2.0.zip
installing terraform template
iac/base already exists, ignoring

done

And then bring up the new environment (no need to apply base again since it's shared):

cd ../prod
terraform init && terraform apply

You'll end up with a directory structure that looks something like this:

.
|____iac
| |____base
| |____env
| | |____dev
| | |____prod
CI/CD (coming soon)

Using this technique, it's easy to codegen CI/CD pipelines for many popular build tools. The build command support this. For example:

$ fargate-create build circleciv2
Extensibility

fargate-create can scaffold out any Terraform template (specified by -t) that meets the following requirements:

  • base and env/dev directory structure
  • a env/dev/main.tf with an s3 remote state backend
  • app and environment input variables

Optionally:

  • add a fargate-create.yml (example here) to your template to drive custom configuration, prompting for defaults, etc.

For example (coming soon):

$ fargate-create -f my-scheduledtask.tfvars -t https://github.com/example/terraform-scheduledtask/archive/v0.1.0.zip

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL