ApiGatewayDeployment - The REST API doesn't contain any methods

During deploy I’m getting this error & I couldn’t fix it until now:

ApiGatewayDeployment - The REST API doesn't contain any methods (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException

I have an API definition in my serverless.yml:

resources:
  Resources:
    ApiGatewayRestApi:
      Type: 'AWS::ApiGateway::RestApi'
      Properties:
        Name: ${self:provider.apiName}
        Body: ${file(swagger-file.yml)}

    ApiGatewayDeployment:
      Type: 'AWS::ApiGateway::Deployment'
      Properties:
        RestApiId:
          Ref: ApiGatewayRestApi
        StageName: ${self:provider.stage}

Any suggestions?

1 Like

I have the same issue now. Were you able to figure out the solution to this?

The AWS::ApiGateway::Deployment needs DependsOn attribute on one AWS::ApiGateway::Method, otherwise CloudFormation will try to create the deployment before the API is ready.

2 Likes

I also faced the same issue. I’m using serverless “function” to create my rest api. As AWS docs says AWS::ApiGateway::Deployment needs DependsOn attribute on one AWS::ApiGateway::Method, therefore I added DependsOn as mentioned below:

ApiGWCustomDomain:
Type: AWS::ApiGateway::DomainName
Properties:
DomainName: ${self:custom.config.environment.domain}
RegionalCertificateArn: ${self:custom.config.environment.certificateArn}
EndpointConfiguration:
Types:
- REGIONAL
SecurityPolicy: TLS_1_2

ApiGatewayDeployment:
Type: AWS::ApiGateway::Deployment
DependsOn:
- ApiGatewayMethodHealthGet
- ApiGWCustomDomain
Properties:
Description: ${env:STAGE} environment
RestApiId:
Ref: ApiGatewayRestApi
StageName: ${env:STAGE}

See if this helps!