Learning center

AWS deployment failure signatures: startup, placement, health, routing or scaling

When an AWS deployment fails, its first record, such as a stop code, service event, target health reason or scaling activity, names the layer that failed. Read it before you read application logs, then run the one check that separates that layer from its nearest neighbor.

One symptom, five layers#

"The deployment failed" is what the pipeline reports. On Amazon ECS the same red build can come from five places, and each leaves a different record:

  • Startup. ECS placed the task but it never reached RUNNING: an image, a secret, a log group or a volume was missing or unreachable.
  • Placement. ECS could not find capacity for the task at all, so no task exists to inspect.
  • Process exit. The container started and its main process exited.
  • Health. The process kept running but failed a load balancer or container health check, and the service scheduler replaced it.
  • Routing and scaling. Every new task is healthy, yet requests fail at the load balancer, or the task count moved for a reason that has nothing to do with the release.

The layer decides who acts next. A startup failure is usually a configuration or permission change in the release. A placement failure is capacity or quota. A health failure can be the release or a dependency the health check calls. Reading the logs of a task that never started wastes the first ten minutes of an incident, because there are no logs.

Where each signature is recorded#

ECS records why every service task stopped in two fields: stopCode, a fixed category, and stoppedReason, free text with the details. The API currently defines seven stop codes. AWS notes that stopped-reason text can change, so sort on the stop code and read the reason for detail. Task fields · Viewing stopped task errors · Stopped-task message updates

Layer and recordDocumented signatureWhat separates it from the next layer
Placement (service events)service (SERVICE) was unable to place a task because no container instance met all of its requirements.No stopped task exists for the new deployment.
Startup (stopped task)Stop code TaskFailedToStart; reason begins with a category such as CannotPullContainerError or ResourceInitializationErrorThe task has no startedAt.
Process exit (stopped task)Stop code EssentialContainerExited; the container's exitCodestartedAt is set and the container reports an exit code.
Health (stopped task and target health)Stop code ServiceSchedulerInitiated; reason beginning Task failed ELB health checks or Task failed container health checksThe process was still running when ECS stopped it.
Scaling (stopped task)Stop code ServiceSchedulerInitiated; reason Scaling activity initiated by (deployment ...)ECS stopped a healthy task to hold the desired count. On an old deployment's task during a rollout, that is a normal retirement. On a new deployment's task, either the desired count went down or a rollback or later deployment is retiring it; the service events and scaling activity tell which.
Outside the release (stopped task)Stop codes SpotInterruption, TerminationNotice, UserInitiatedCapacity was reclaimed, or a person or tool stopped the task.

Routing failures leave no stopped task at all. The tasks are healthy and the load balancer's own metrics carry the signature: HTTPCode_ELB_5XX_Count counts errors the load balancer generated, while HTTPCode_Target_5XX_Count counts errors your tasks returned. ALB CloudWatch metrics

Collect every signature in one pass#

Run these three reads as soon as the deployment fails. ECS keeps stopped tasks for at least one hour and returns only the latest 100 service events, so a slow incident loses the evidence. Use a read-only profile and replace the uppercase placeholders. Stopped task retention · Service fields

aws ecs describe-services \
  --profile PROFILE --region REGION --cluster CLUSTER --services SERVICE \
  --query 'services[0].{deployments:deployments[].{id:id,status:status,definition:taskDefinition,rollout:rolloutState,reason:rolloutStateReason,failed:failedTasks,created:createdAt},events:events[:20].[createdAt,message]}' \
  --output json --no-cli-pager

aws ecs list-tasks \
  --profile PROFILE --region REGION --cluster CLUSTER \
  --service-name SERVICE --desired-status STOPPED \
  --query 'taskArns' --output json --no-cli-pager

aws ecs describe-tasks \
  --profile PROFILE --region REGION --cluster CLUSTER --tasks TASK_ARN_1 TASK_ARN_2 \
  --query 'tasks[].{deployment:startedBy,definition:taskDefinitionArn,started:startedAt,stopped:stoppedAt,code:stopCode,reason:stoppedReason,containers:containers[].{name:name,exit:exitCode,reason:reason}}' \
  --output json --no-cli-pager

startedBy holds the ECS deployment ID for tasks a service started, so it splits the new deployment's tasks from the old ones. failedTasks counts consecutive failures in a deployment: tasks that could not launch, never reached RUNNING, or failed a health check and were stopped. It resets once the deployment has a running task. Deployment fields

Then sort. If the new deployment has no stopped tasks and the events mention placement, go to placement. If its tasks stopped, group them by stop code and read the stop code guide for each group.

An illustrative event sequence#

The service orders moves from task definition orders:57 to orders:58. The pipeline reports a failed deployment at 10:14. These are fictional records, trimmed to the fields above; reasons are summarized where AWS does not publish the full text.

TimeRecordValue
09:58Deploymentecs-svc/2211 created for orders:58, desired count 4
10:00Stopped task, deployment ecs-svc/2211TaskFailedToStart; the reason begins ResourceInitializationError and names the awslogs log group, which does not exist
10:01Stopped task, deployment ecs-svc/2211Same stop code and reason
10:03Stopped task, deployment ecs-svc/1987 (old)SpotInterruption, Your Spot Task was interrupted.
10:06Service eventservice (orders) is unable to consistently start tasks successfully.
10:14Deploymentecs-svc/2211 rollout state FAILED

Three of these records look alarming and only two belong to the release. The two TaskFailedToStart tasks belong to the new deployment and never started, so there are no application logs to read. Their reason names the awslogs log driver: orders:58 points at a log group that does not exist in this Region. The Spot interruption hit an old task from ecs-svc/1987. It explains a dip in running count during the rollout but not the failure. Rolling back to orders:57 would restore service, and the fix is the log group reference in revision 58. Missing log group

Change one record and the reading changes. If the 10:00 tasks had stopped with EssentialContainerExited and exit code 1, the release started and crashed, and the container logs are the next read. If they had stopped with a reason beginning Task failed ELB health checks, check whether the old tasks were failing the same check before you blame the release.

Startup: the task never ran#

A task with no startedAt failed before its essential container ran. The stopped reason starts with a category that names the failing step:

Placement: no task to inspect#

When no stopped task belongs to the new deployment, the service events explain why ECS did not place one. The event text names the constraint that failed, such as CPU, memory, ports, an attribute or an account limit. Service event messages

Running tasks that stopped or never retired#

Once a task has a startedAt, the stop code and the deployment ID sort it. Read the stop code first, then:

Routing: healthy tasks, failing requests#

Other AWS deployment tools#

Each AWS deployment service has its own fixed field for the same question.

EC2 Auto Scaling records each launch and termination as a scaling activity with a StatusCode and StatusMessage. The guides cover insufficient capacity, a launch template version that fails every launch, Client.InternalError on encrypted volumes, ELB health checks replacing new instances, a failed instance refresh and a lifecycle hook that abandoned the launch. Activity

CodeDeploy puts a code such as HEALTH_CONSTRAINTS or TIMEOUT in errorInformation, and each instance or task set records the lifecycle event that failed. The guides cover ScriptFailed, HEALTH_CONSTRAINTS, events stuck in Pending and an ECS blue/green hook. ErrorInformation

Lambda reports a failed deploy in LastUpdateStatus and LastUpdateStatusReasonCode, such as SubnetOutOfIPAddresses. The guides cover failed updates by reason code, init errors after a deploy and a canary that rolled back. Function states

CloudFormation puts the cause in ResourceStatusReason on the first failed resource event. The guides cover an ECS service that did not stabilize, UPDATE_ROLLBACK_FAILED and a custom-named resource that needs replacing. Stack events

EKS managed node groups list health issues with a code such as NodeCreationFailure. The guides cover health issue codes and PodEvictionFailure during an update. Issue

Where a signature stops helping#

A signature names the layer, not the cause behind it. A reason beginning Task failed ELB health checks says the scheduler replaced a running task; it does not say whether the new code broke the health endpoint or the database the endpoint queries went down. The stopped reason is free text that AWS may reword, so do not build alerting on its exact wording; use stopCode and keep the reason as evidence. A stopped task also expires: if you arrive more than an hour after the failure, the service events and any EventBridge task state change events you retained are what remains. Task state change events

Bring the signature into the pull request#

Most startup signatures trace back to one changed line in a task definition, IAM policy or log configuration. Put the failing revision's diff and the signature you recorded in the pull request that fixes it, so the reviewer can check the fix against the evidence. Proofline reviews GitHub pull requests; new organizations get one calendar month of hosted code review without a cloud connection. Start a free GitHub review · Eligibility and fair-use terms · Current product availability

Questions#

What is the difference between stopCode and stoppedReason in ECS?

stopCode is one of a fixed set of categories, such as TaskFailedToStart or EssentialContainerExited. stoppedReason is free text with the details, such as which image or log group failed. Sort and alert on the stop code, and read the reason for the specific cause.

Why does my failed ECS task have no logs?

If the task has no startedAt, its essential container never ran, so it wrote nothing. The failure happened during image pull or resource initialization. The stopped reason is the evidence; application logs are not.

How long does ECS keep stopped tasks?

AWS shows stopped tasks for at least one hour after they stop. Capture describe-tasks output early, or keep ECS task state change events in EventBridge if you need the records later.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading