Interview Prep/AWS/ECS, EKS, ECR and Lambda

An ECS deployment rolls back automatically, and the event says `deployment failed: tasks failed to start` from the circuit breaker.

AdvancedTroubleshootingECS, EKS, ECR and Lambda
Answer

Likely causes → The new tasks crash at startup (bad config or secret, failed migration), fail the container health check, or fail ALB health checks before healthCheckGracePeriodSeconds. The deployment circuit breaker detected repeated failures and rolled back.

Diagnose →

aws ecs describe-services --cluster prod --services api \
  --query 'services[].[deployments,events[:10]]'
aws ecs list-tasks --cluster prod --service-name api --desired-status STOPPED
aws ecs describe-tasks --cluster prod --tasks <stopped-task> --query 'tasks[].[stoppedReason,containers[].[exitCode,reason]]'
aws logs tail /ecs/api --since 20m --filter-pattern ERROR

Fix →

  1. Fix the root cause from the stopped-task reasons and logs
  2. If the app is slow to start, raise healthCheckGracePeriodSeconds and the container health check startPeriod
  3. Redeploy

Prevent → Keep the circuit breaker with rollback on, add CloudWatch alarm-based rollback, and smoke-test images in staging with the same task definition.

aws All AWS questions Roadmap: EKS, ECS & serverless on AWS

More on ECS, EKS, ECR and Lambda