A dead simple example to setup AWS Fargate using Fargate CLI + Terraform
- Use Terraform to setup AWS ECS basic environment
- Use Fargate CLI to create Fargate services without hassle
- Zero-downtime deploy thanks to Fargate
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.
- Install prerequisites
cp aws-credentials.ini.example aws-credentials.ini
# Add your credentials
vim aws-credentials.ini
# Initialize Terraform
make init
make create
make info
make deploy
Note: This will build Dockerfile
in the current directory. If you have other deploy strategy, edit Makefile
.
make destroy
Note: ECS Execution Role will not be deleted.
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