Ravindra BagaleCourses & study guides मराठी

Chapter 89: Amazon ECS for DevOps

DevOps

89.10 Lab — Fargate service from an ECR image

Story. You are helping a Zerodha-style API team train juniors. Real Fargate and ALB spend money (approximate — check pricing). In class you walk the full shape: Dockerfile → ECR → task definition → Fargate service → logs. Create resources only in a funded lab account your teacher names, and delete them the same day.

Lab steps

  1. Build a tiny HTTP app image locally (any language you already use). Expose port 8080 and a /healthz that returns 200.
  2. Create an ECR repository pay-api-lab in ap-south-1 (or skip create if the teacher gives one).
  3. Login, tag, and push the image. Copy the image URI.
  4. Create an IAM task execution role and a tight task role (even if the app needs no AWS APIs yet — practice the split).
  5. Register a Fargate task definition: CPU 256, memory 512, awsvpc, awslogs to /ecs/pay-api-lab, both role ARNs, container port 8080.
  6. Create cluster shop-lab if needed. Create a Fargate service with desired count 1 in private subnets (or public only if the lab design requires assignPublicIp=ENABLED — follow the teacher).
  7. Optional: attach an ALB target group and health check on /healthz.
  8. Run aws ecs describe-services until runningCount is 1. Tail CloudWatch logs.
  9. Push a second tag, register revision 2, update-service, confirm a new deployment.
  10. Delete the service, task definitions you created, load balancer pieces, and the image repo if policy allows — stop charges the same day.

What good looks like

  • You can explain cluster vs task definition vs service in one minute.
  • You never pasted real AWS access keys into Git or a lesson file.
  • Logs appear in CloudWatch without SSH.
  • You know approximate cost levers: Fargate vCPU/memory time, ALB-hours, NAT, log retention — and you verify on AWS pricing pages.
  • Teardown is part of the lab, not an afterthought.

Funded account only. Delete lab ECS services and ALBs the same day. Local docker run is fine when AWS is not funded.

Did you understand? Let us try it once more.