Skip to content
Latchkey

CloudFormation "Resource ... did not stabilize" in CI

CloudFormation waited for a resource to report a stable state (an ECS service reaching steady state, an RDS instance becoming available) and it never did within the allowed window, so the operation fails and rolls back.

What this error means

A long-running resource fails with "did not stabilize" or "Resource is not in the state <X>" after several minutes, often ECS services, RDS, or custom resources.

CloudFormation
CREATE_FAILED   AWS::ECS::Service   WebService
Resource handler returned message: "Resource of type 'AWS::ECS::Service' with identifier
'web' did not stabilize."

Common causes

The underlying resource is unhealthy

An ECS task keeps crashing, a health check fails, or an RDS instance cannot reach available, so the resource never stabilizes.

A custom resource never signals success

A Lambda-backed custom resource does not send the SUCCESS response, so CloudFormation waits until it times out.

How to fix it

Diagnose the resource health

  1. Open the resource in its own console (ECS service events, RDS events, CloudWatch logs).
  2. Fix the failing task, health check, or configuration that blocks the ready state.
  3. Redeploy once the resource can reach a stable state on its own.

Ensure custom resources respond

Make the custom resource Lambda always send a response (SUCCESS or FAILED) even on error, so CloudFormation does not wait for the full timeout.

index.py
import cfnresponse
def handler(event, context):
    try:
        cfnresponse.send(event, context, cfnresponse.SUCCESS, {})
    except Exception:
        cfnresponse.send(event, context, cfnresponse.FAILED, {})

How to prevent it

  • Validate health checks and task definitions before deploy.
  • Always send a cfnresponse from custom resource handlers.
  • Set realistic creation timeouts for slow resources.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →