Based on the AWS ECS workshop
Rewrite CloudFormation core stack and provision scripts into Terraform
- Used file-layout isolation (per services and per environment)
- Used S3 remote backends isolation (per services and per system)
- Used simple ALB module from example repo
- Used static files S3 and DynamoDB data fast deployment with terraform (not production-ready solution)
Prerequisites:
- terraform >= 0.13
- amazon-ecr-credential-helper (for push images into ECR)
- tfsec >= v0.36.11 (for pre-commit usage)
- tflint >= 0.23.0 (for pre-commit usage)
- checkov >= 1.0.675 (for pre-commit usage)
Pre-commit installation:
git secrets --install
pre-commit install -f
pre-commit run -a
- Create buckets and DynamoDB table for Terraform remote backends (global/s3)
cd global/s3
make plan
make apply
-
Configure backend.config and terraform.tfvars with details in each Staging dir
-
Create Staging ECR (staging/ecr)
cd staging/ecr
make plan
make apply
- Build Docker images and push it to ECR via script:
cd app
./build_images.sh <aws account id>
- Create DynamoDB table with data (staging/dynamodb)
cd staging/dynamodb
make plan
make apply
- Create Staging VPC (staging/vpc)
cd staging/vpc
make plan
make apply
- Create Staging ECS cluster (staging/ecs) and check API ALB endpoint
cd staging/ecs
make plan
make apply
- Upload FrontEnd (staging/s3web) and check S3 website URL
cd staging/s3web
make plan
make apply
- Load testing example to check ECS Like service AutoScaling
ab -p data.json -c 20 -n 10000 <ALB FQDN>/mysfits/33e1fbd4-2fd8-45fb-a42f-f92551694506/like
- Destroy Infrastructure in strict reverse order, otherwise tfstate dependenices will be broken