This page is generated from skills/ecs-devops/references/failure-detection-and-rollback.md. Edit the source, not this page.
ECS DevOps — Failure Detection & Rollback
Part of: ecs-devops Purpose: Deployment circuit breaker (including the Jul 2026 configurable thresholds), CloudWatch alarm-based failure detection, and every rollback path for ECS deployments
For strategy configuration, see: deployment-strategies.md
Facts in this file verified 2026-07-09 against the AWS documentation URLs cited inline.
Table of Contents
- Deployment Circuit Breaker
- Configurable Thresholds (Jul 2026)
- CloudWatch Alarm-Based Detection
- Combining Both Methods
- The Rollback Ladder
- What --force-new-deployment Actually Does
- Observability of Deployments
Deployment Circuit Breaker
Source: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-circuit-breaker.html (verified 2026-07-09)
- Scope: rolling update under the
ECSdeployment controller only. Not blue/green-family (those rely on hooks, bake time, and stage timeouts), not CodeDeploy, not external. Launch types: the GA announcement names EC2 and Fargate (GA What's New, Dec 2020); the current doc scopes the feature only by deployment controller and says nothing about launch types (circuit breaker). Circuit-breaker support on theEXTERNALlaunch type (ECS Anywhere) is not explicitly documented — verify before relying on it. If it does apply there, note that stage-2 detection reduces to ECS container health checks only (no ELB and no service discovery/Cloud Map on Anywhere — ECS Anywhere). - Two-stage detection:
- Stage 1 — tasks failing to reach
RUNNINGcount toward the threshold (task-launch failures: image pull errors, missing secrets, ENI/placement failures…). - Stage 2 — once at least one task is RUNNING, health-check failures count, across ELB health checks, AWS Cloud Map service health checks, and ECS container health checks.
- Stage 1 — tasks failing to reach
- Rollback target: the most recent deployment in
COMPLETEDstate. During rollback that deployment moves back toIN_PROGRESS(and is not re-rollback-eligible until COMPLETED again). If no COMPLETED deployment exists (e.g., first-ever deployment fails), the circuit breaker does not launch new tasks and the deployment stalls — clean up manually. - Version-consistency interplay: with circuit breaker enabled, 3+ failed image-digest-resolution attempts fail the deployment and trigger rollback (rolling deployment).
CLI shape (rolling only):
aws ecs update-service --cluster prod --service web \
--deployment-configuration \
'deploymentCircuitBreaker={enable=true,rollback=true,resetOnHealthyTask=false,thresholdConfiguration={type=COUNT,value=5}}'
History: GA Dec 2020; monitoring-responsiveness improvement Jan 2024 (What's New); configurable settings Jul 1, 2026 (What's New).
Configurable Thresholds (Jul 2026)
Source: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-circuit-breaker.html (verified 2026-07-09; launched Jul 1, 2026)
deploymentCircuitBreaker.thresholdConfiguration:
type | Formula | Notes |
|---|---|---|
BOUNDED_PERCENT (default) | threshold = ceil(value% × desired count), clamped to min 3 / max 200 | value default 50, valid 1–100 |
UNBOUNDED_PERCENT | same formula, no clamps | For very large services where the 200 cap is too tight |
COUNT | threshold = value (fixed number of failed tasks) | Deterministic; good for small services |
Worked examples from the AWS doc (value 50, BOUNDED_PERCENT): desired 1 → threshold 3 (floor clamp); desired 25 → 13 (ceil); desired 400 or 800 → 200 (cap). UNBOUNDED_PERCENT, desired 800, value 50 → 400. ECS continuously uses the latest desired count during a deployment (autoscaling mid-deploy moves the threshold).
deploymentCircuitBreaker.resetOnHealthyTask:
true(default) — consecutive failure counting; the failure counter resets whenever a healthy task starts. A deployment that limps (fail, fail, healthy, fail, fail…) may never trip.false— cumulative counting across the whole deployment; stricter, better for catching intermittent-failure deployments.
CloudWatch Alarm-Based Detection
Sources: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-alarm-failure.html and https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DeploymentAlarms.html (verified 2026-07-10)
- Config:
deploymentConfiguration.alarms={alarmNames=[...],enable=true,rollback=true}. Scope is controller-based, not strategy-based: any strategy under theECSdeployment controller (not CODE_DEPLOY/EXTERNAL). API_DeploymentAlarms restricts alarms only to "when the DeploymentController is set to ECS", and AWS's blue/green service definition configuresalarmsalongside"strategy": "BLUE_GREEN"(deploy-blue-green-service, verified 2026-07-10). One sentence on the alarm-detection page says "only supported for … the rolling update (ECS) deployment controller" — "rolling update (ECS)" there is the doc's label for the controller; do not read it as rolling-only. Contrast: the rolling-only restriction genuinely applies to the circuit breaker (API_DeploymentConfiguration attaches its rolling-only note todeploymentCircuitBreaker, notalarms). - Bake time: alarm monitoring starts after all target-revision tasks are running/healthy and old revisions are scaled to zero, and continues for a bake period (the doc states only that the default bake time is "less than 5 minutes" — AWS does not publish an exact value). The deployment stays
IN_PROGRESSuntil the bake completes — raise CloudFormation/pipeline timeouts accordingly. - Gotchas (both documented):
- ECS polls alarms via
DescribeAlarms, which counts against CloudWatch API quotas — heavy account-wideDescribeAlarmsusage can throttle ECS's polling, causing a missed alarm and a skipped rollback. - If an alarm is already in
ALARMstate when the deployment starts, ECS ignores the alarm configuration for that deployment — deliberately, so you can deploy a fix for the very thing that is alarming.
- ECS polls alarms via
- Recommended alarm metrics (from the doc): ALB
HTTPCode_ELB_5XX_Count/HTTPCode_ELB_4XX_Count, serviceCPUUtilization/MemoryUtilization, SQSApproximateNumberOfMessagesNotVisible. Choose metrics that regress quickly when a bad revision ships. (For designing the broader alarm/dashboard stack, route to theecs-observabilityskill.)
Launch-type note: alarm detection is metric-driven; the docs scope it only by deployment controller, and EC2/Fargate are covered explicitly. Managed Instances support is inferred, not explicitly documented as of 2026-07-10 — verify (same posture as the ECS Anywhere circuit-breaker caveat above). On ECS Anywhere there is no ELB, so any alarm use there must rest on service/application metrics, not ALB metrics.
Combining Both Methods
Sources: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-type-ecs.html and https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-alarm-failure.html (verified 2026-07-09)
- Circuit breaker and alarms can be used separately or together. When both are configured, the deployment fails as soon as either criterion is met — first to trip wins.
- Rollback happens if the tripping method has rollback enabled — enable rollback on both unless you have a reason not to.
- Division of labor: circuit breaker catches "tasks can't start / can't get healthy"; alarms catch "tasks are healthy but the application regressed" (error rates, latency, backlog).
The Rollback Ladder
Ordered fastest-first. Sources cited per rung (verified 2026-07-09).
- Bake-time weight flip (blue/green-family only). While blue still runs, rollback is a listener-rule weight change back to blue — near-instant, no task relaunch. Triggered automatically by hook failures and stage timeouts, or manually (rung 2). (how blue/green works)
stop-service-deploymentwith ROLLBACK (any strategy under theECScontroller; GA May 5, 2025 — What's New):Rolls back to the previous service revision even if rollback was never configured on the service. Stoppable states:aws ecs list-service-deployments --cluster prod --service webaws ecs stop-service-deployment \--service-deployment-arn <arn> --stop-type ROLLBACKPENDING,IN_PROGRESS(→ROLLBACK_REQUESTED),STOP_REQUESTED,ROLLBACK_REQUESTED,ROLLBACK_IN_PROGRESS. (stop-service-deployment, verified 2026-07-10). Note: the API_StopServiceDeploymentstopTypeenum listsABORT | ROLLBACK, while its prose says the valid value isROLLBACK— useROLLBACK.- Automatic rollback — circuit-breaker trip (rolling only), alarm trip (any
ECS-controller strategy), lifecycle-hook FAILED/ROLLBACK, pause-hook timeout with ROLLBACK action, or a 24 h stage timeout (blue/green-family). Target: most recentCOMPLETEDdeployment. (circuit breaker, pause hooks) - Manual re-deploy of the previous task-definition revision via
UpdateService— the universal fallback under theECSand CodeDeploy controllers. It does not work under theEXTERNALcontroller: thereUpdateServicechanges only desired count and health-check grace period, so roll back by shifting traffic/scale back to your previous task set (deployment-type-external; see controllers-and-migration.md). CodeDeploy-controller rollback reroutes traffic back to the original task set. (CodeDeploy ECS steps)
What --force-new-deployment Actually Does
Sources: https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html#ECS-UpdateService-request-forceNewDeployment and https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-ecs-service.html#cfn-ecs-service-forcenewdeployment (verified 2026-07-10)
aws ecs update-service --force-new-deployment starts a new deployment with no service-definition changes. It is a restart/re-pull, not a rollback:
- Legitimate uses: pull a newer image behind the same mutable tag (
my_image:latest), move Fargate tasks onto a newer platform version, restart the application fleet, re-establish image digests (updated digests apply to newly launched tasks only). - Why it can't roll back: it redeploys the same task definition the service already points at. If that revision is the broken one, forcing "redeploys the outage".
- Prefer immutable tags + a new task-definition revision over mutable-tag force-redeploys — force-redeploying
latestmakes what's running unauditable. - For an actual rollback, use rung 2 or 4 above.
Observability of Deployments
Sources: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-circuit-breaker.html and https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_service_deployment_events.html (verified 2026-07-09)
aws ecs describe-servicesexposes per-deploymentrolloutState(IN_PROGRESS→COMPLETED/FAILED) androlloutStateReason. AFAILEDdeployment launches no new tasks.- ECS emits EventBridge service-deployment state-change events — alert on
eventName = SERVICE_DEPLOYMENT_FAILED. Rollback-initiated deployments carry areasonfield indicating the rollback. aws ecs describe-service-deploymentsshows deployment/hook detail (includinglifecycleHookDetailswith pause-hookhookIds).- Pause hooks emit
ECS Hook State Changeevents with statusHOOK_AWAITING_ACTION— the trigger for approval workflows. - Building the dashboards/alerting stack around these events is
ecs-observabilityterritory; this skill owns which events matter for release safety.