flowchart LR
I[Image in ECR] --> TD[Task definition]
TD --> S[ECS service on Fargate]
S --> L[Application Load Balancer]
- Push the image to ECR:
aws ecr get-login-password --region ap-south-1 | docker login --username AWS \
--password-stdin 111122223333.dkr.ecr.ap-south-1.amazonaws.com
docker tag app:1.0 111122223333.dkr.ecr.ap-south-1.amazonaws.com/app:1.0
docker push 111122223333.dkr.ecr.ap-south-1.amazonaws.com/app:1.0
- Create a task definition: CPU and memory (for example 0.5 vCPU and 1 GB), the image, port mappings and a log configuration using
awslogs. - Create a service with a desired count of 2, in private subnets, attached to an ALB target group.
- Use two roles: the task execution role (pull the image, write logs) and the task role (what your code may call).
Set a health check on the target group and enable deployment circuit breaker so a bad release rolls back. Fargate supports Graviton (ARM) tasks for lower cost if your image is built for arm64. Compare with EKS: ECS is simpler when you do not need the Kubernetes ecosystem.