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:
- A manual
AWS::ApiGateway::DeploymentalongsideAWS::Serverless::Api. SAM already generates a deployment; the handwritten one races the SAM-generated methods. - Raw CloudFormation templates where the
DeploymentlacksDependsOnentries for the methods. - An
AWS::Serverless::Apiwith no routes at all — no function declares anApievent referencing it and its OpenAPI definition defines no paths — so the API really does have zero methods.
FIX
How to fix it
-
Prefer the SAM-managed deployment. If the template uses
AWS::Serverless::Api(or implicit APIs from functionApievents), delete the handwrittenAWS::ApiGateway::Deployment/Stagepair and let SAM generate them. This removes the race entirely. -
If you must manage the deployment manually, declare the
ordering explicitly — every method the snapshot needs:
Remember to add each new method to that list; a forgotten one reintroduces the race intermittently.ApiDeployment: Type: AWS::ApiGateway::Deployment DependsOn: - GetItemsMethod - PostItemMethod Properties: RestApiId: !Ref MyRestApi -
Confirm the API actually has routes. Check the
transformed template to see what SAM generated:
If nosam validate --lint aws cloudformation get-template --stack-name YOUR_STACK \ --template-stage ProcessedAWS::ApiGateway::Methodresources exist, wire a function to the API with anApievent or define paths in the OpenAPI body. -
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
Related errors
- ROLLBACK_COMPLETE state and can not be updated — the state this failure leaves a first deploy in.
- InsufficientCapabilitiesException — the other classic first-deploy stopper.
- Esbuild Failed: Cannot find esbuild — a build-time failure in the same serverless API stacks.