Analysing Failed Processes in Auto Scaling, Amazon ECS and Amazon EKS
Compute platforms report failures in their own ways: Auto Scaling activity history, ECS stopped reasons and service events, Kubernetes pod states and events. This lesson explains where to find the evidence for each platform and how to interpret the most common failure messages, so that incidents involving scaling and containers can be diagnosed quickly.
Learning outcomes
After completing this lesson, you will be able to:
- Diagnose Auto Scaling failures from activity history, health replacement events and lifecycle hook behaviour.
- Interpret ECS stopped reasons, exit codes and service events for failed tasks and deployments.
- Interpret Kubernetes pod states and events on Amazon EKS, including Pending, ImagePullBackOff, CrashLoopBackOff and OOMKilled.
- Identify the logs and metrics that support container troubleshooting.
Auto Scaling Failures
The activity history of an Auto Scaling group records every launch and termination with its cause and status, and failed activities include the error message. EventBridge receives EC2 Instance Launch Unsuccessful and EC2 Instance Terminate Unsuccessful events for automated alerting. Common situations are summarised below.
| Symptom | Evidence | Cause |
|---|---|---|
| Capacity does not increase | Desired capacity at maximum | Maximum too low |
| Launches fail | Activity history: InsufficientInstanceCapacity, vCPU limit exceeded, invalid AMI, insufficient IPs, permissions on KMS-encrypted volumes | Capacity, quotas, launch template errors, KMS key policy |
| Instances launched and terminated repeatedly | Activity history: instances replaced as unhealthy shortly after launch | Health check grace period too short, or application failing ELB health checks |
| Instances stuck in Pending:Wait | Lifecycle state | A launch lifecycle hook waiting for CompleteLifecycleAction until its heartbeat timeout |
| Unbalanced AZs | Rebalancing activities | Capacity unavailable in an AZ; rebalancing in progress |
A failure launching instances with encrypted EBS volumes is a common trap: the Auto Scaling service-linked role must be allowed to use the customer managed KMS key in the key policy, otherwise instances terminate immediately with a client error.
Amazon ECS Failures
ECS records why each task stopped. The stopped reason and each container's exit code and reason appear in the console and in DescribeTasks output for about an hour after the task stops, and ECS task state change events in EventBridge preserve them longer. Service events describe scheduler activity, such as being unable to place tasks. Container logs in CloudWatch Logs show application errors, and Container Insights shows resource usage.
| Stopped reason or event | Meaning and typical fix |
|---|---|
| CannotPullContainerError | Image not found or not accessible: wrong URI or tag, missing ECR permissions on the task execution role, or no route to ECR (NAT or VPC endpoints for ECR API, ECR DKR and S3) |
| ResourceInitializationError: unable to pull secrets or registry auth | Task execution role lacks Secrets Manager, Parameter Store or KMS permissions, or no network path to those services |
| Essential container in task exited | The application exited; check the exit code and container logs |
| Exit code 137 or OutOfMemoryError | Container killed for exceeding its memory limit; raise memory or fix the leak |
| Exit code 1 or other non-zero | Application error, often configuration or a missing dependency |
| Task failed ELB health checks | Wrong health check path or port, slow start-up (add a grace period), or security groups blocking the load balancer |
| Service event: unable to place a task because no container instance met all of its requirements | Insufficient CPU, memory or ports on EC2 capacity, or placement constraints |
| Deployment circuit breaker rolled back | New tasks repeatedly failed to reach a steady state |
Decode the ECS stop reason
Amazon EKS Failures
Kubernetes reports problems through pod status and events, read with kubectl get pods, kubectl describe pod (which lists events) and kubectl logs, including --previous for a restarted container. Container Insights and control plane logs in CloudWatch provide history. Common states are explained below.
| Pod state or event | Meaning | Typical causes |
|---|---|---|
| Pending (FailedScheduling) | No node can run the pod | Insufficient CPU or memory, node selectors or taints, autoscaler limits, no IP addresses available |
| ImagePullBackOff or ErrImagePull | The image cannot be pulled | Wrong image name, node role lacks ECR permissions, no route to the registry |
| CrashLoopBackOff | The container starts and exits repeatedly | Application error, bad configuration, failing liveness probe |
| OOMKilled | The container exceeded its memory limit | Limit too low or a memory leak |
| Running but not Ready | Readiness probe failing | Application not ready, wrong probe path or port |
| Node NotReady | Node unhealthy | Kubelet or networking problems, resource exhaustion |
| AccessDenied from AWS SDK in a pod | Pod has no or wrong AWS credentials | Missing EKS Pod Identity association or IRSA annotation, or role trust policy |
Cluster access problems, such as kubectl returning Unauthorized, usually mean the IAM principal has no access entry or the wrong access policy for the namespace. IP exhaustion with the VPC CNI appears as pods stuck creating with errors about assigning IP addresses.
Decode the pod status
A Service That Never Becomes Healthy
A new ECS service on Fargate in private subnets never reaches its desired count. Tasks appear briefly and stop, and the deployment circuit breaker rolls back.
-
Read the stopped reason
DescribeTasks shows ResourceInitializationError: unable to pull secrets.
-
Check permissions
The task execution role has secretsmanager:GetSecretValue on the secret, and the secret uses the AWS managed key, so permissions are adequate.
-
Check the network
The subnets have no NAT gateway, and the VPC has endpoints only for ECR and S3, so the task cannot reach Secrets Manager.
-
Fix
Add an interface endpoint for Secrets Manager (and CloudWatch Logs, which the awslogs driver also needs); the next deployment reaches a steady state.
Pods in an EKS deployment show CrashLoopBackOff. Which commands give the most direct evidence?
Show answer
kubectl describe pod for events and the last state with exit code, and kubectl logs --previous to read the output of the crashed container.
Exam Tips
Remember for the exam
- Auto Scaling activity history shows launch and termination failures; encrypted volumes need the Auto Scaling service-linked role in the KMS key policy.
- ECS: CannotPullContainerError (image, permissions or network), ResourceInitializationError (secrets or logs access), exit code 137 (out of memory), ELB health check failures.
- EKS: Pending (scheduling or capacity), ImagePullBackOff, CrashLoopBackOff, OOMKilled; use kubectl describe, logs --previous and events.
- Private subnets need VPC endpoints or NAT for ECR, S3, Secrets Manager and CloudWatch Logs.