acro5piano / terraform-fargate-example

A dead simple example to setup AWS Fargate using Fargate CLI + Terraform

Home Page:https://dev.to/acro5piano/run-docker-containers-with-fargate-cli-terraform-in-aws-3hmf

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform & Fargate example

A dead simple example to setup AWS Fargate using Fargate CLI + Terraform

Features

  • Use Terraform to setup AWS ECS basic environment
  • Use Fargate CLI to create Fargate services without hassle
  • Zero-downtime deploy thanks to Fargate

Why

We can create all of AWS ECS environment with Terraform. However, it requires a lot of Terraform boilerplates and understanding how Terraform works. Instead of copy & paste HCL from the Terraform document, let's delegate some parts to Fargate CLI.

How to use

Initial Setup

cp aws-credentials.ini.example aws-credentials.ini

# Add your credentials
vim aws-credentials.ini

# Initialize Terraform
make init

Create service

make create

Show information

make info

Deploy service

make deploy

Note: This will build Dockerfile in the current directory. If you have other deploy strategy, edit Makefile.

Delere everything

make destroy

Note: ECS Execution Role will not be deleted.

What will be created?

By Terraform:

  • ECS Cluser
  • EC2 Security Group
  • ECR Repository

By Fargate CLI:

  • ECS Task Definition
  • ECS Service
  • ECS Task
  • ECS Task Execution Role
  • ALB
  • ALB Target Group
  • CloudWatch Log Group

About

A dead simple example to setup AWS Fargate using Fargate CLI + Terraform

https://dev.to/acro5piano/run-docker-containers-with-fargate-cli-terraform-in-aws-3hmf

License:MIT License


Languages

Language:Makefile 44.7%Language:HCL 36.2%Language:Shell 10.3%Language:JavaScript 6.2%Language:Dockerfile 2.5%