SAM Doctor

ERROR REFERENCE

The REST API doesn't contain any methods

API Gateway refused to create a deployment because, at the moment CloudFormation created the AWS::ApiGateway::Deployment resource, the API had zero methods. It is an ordering problem, not a missing-route problem.

WHAT IT MEANS

What this error means

A REST API deployment snapshots the API's methods. CloudFormation creates resources in dependency order — and it only knows about dependencies that are declared through Ref/GetAtt or DependsOn. A Deployment resource references the API, but nothing forces it to wait for each AWS::ApiGateway::Method. If the deployment wins the race, the API genuinely has no methods yet and this error fails the stack. Typical setups that hit it:

FIX

How to fix it

  1. Prefer the SAM-managed deployment. If the template uses AWS::Serverless::Api (or implicit APIs from function Api events), delete the handwritten AWS::ApiGateway::Deployment/Stage pair and let SAM generate them. This removes the race entirely.
  2. If you must manage the deployment manually, declare the ordering explicitly — every method the snapshot needs:
    ApiDeployment:
      Type: AWS::ApiGateway::Deployment
      DependsOn:
        - GetItemsMethod
        - PostItemMethod
      Properties:
        RestApiId: !Ref MyRestApi
    Remember to add each new method to that list; a forgotten one reintroduces the race intermittently.
  3. Confirm the API actually has routes. Check the transformed template to see what SAM generated:
    sam validate --lint
    aws cloudformation get-template --stack-name YOUR_STACK \
      --template-stage Processed
    If no AWS::ApiGateway::Method resources exist, wire a function to the API with an Api event or define paths in the OpenAPI body.
  4. Redeploy. If the first failed attempt left a new stack in ROLLBACK_COMPLETE, delete it before deploying again.

AUTOMATE THE TRIAGE

Diagnose this automatically

SAM Doctor recognizes this API Gateway ordering failure (high confidence) and suppresses the generic CREATE_FAILED noise around it, so the report points at the deployment/method race instead of the rollback symptoms. Runs locally; no AWS access, no log upload.

python -m pip install sam-doctor
sam-doctor diagnose deployment.log --format markdown

RELATED