title: AWS SAM: The REST API doesn't contain any methods
body: <p>I'm trying to use AWS SAM to deploy a simple API.
  When the API is simple (that is, does not specify explicitly an API Gateway). the deployment succeeds.</p>
  
  <p>However, the following deployment fails:</p>
  
  <pre><code>AWSTemplateFormatVersion: '2010-09-09'
  Transform: AWS::Serverless-2016-10-31
  Description: Sample API
  
  Parameters: 
    Stage:
      Type: String
      AllowedValues: 
        - dev
        - sat
        - demo
        - staging
        - prod
      Description: Enter dev, sat, demo, staging or prod
  
  Resources:
  
    MyApi:
      Type: AWS::Serverless::Api
      Properties:
        StageName: !Ref Stage
        EndpointConfiguration: PRIVATE
        DefinitionBody:
          swagger: '2.0'
          x-amazon-apigateway-policy:
            Version: '2012-10-17'
            Statement:
              - Effect: Allow
                Principal: "*"
                Action: execute-api:Invoke
                Resource:
                  - !Sub arn:aws:execute-api:*:*:*/${Stage}/*
  
    ThumbnailFunction:
      Type: 'AWS::Serverless::Function'
      Properties:
        Runtime: nodejs8.10
        Handler: get-config.handler
        CodeUri: ./functions
        Events:
          ThumbnailApi:
            Type: Api
            Properties:
              RestApiId: !Ref MyApi
              Path: /thumbnail
              Method: GET
  </code></pre>
  
  <p>The error message is the following:</p>
  
  <pre><code>The REST API doesn't contain any methods (Service: AmazonApiGateway;
  Status Code: 400; Error Code: BadRequestException
  </code></pre>
  
  <p>Looking on Google, I do find mentions of this error when manually specifying a deployment (<a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-deployment.html" rel="nofollow noreferrer">here</a>, or <a href="https://forums.aws.amazon.com/thread.jspa?threadID=232074" rel="nofollow noreferrer">here</a>). In my case, the deployment is implicit, hence I assume my issue is different.</p>
  
  <p>The code I'm using is based on a SAM example (<a href="https://github.com/awslabs/serverless-application-model/blob/master/examples/2016-10-31/api_swagger_cors/template.yaml" rel="nofollow noreferrer">here</a>). I'm scratching my head to understand what is wrong with my stack.</p>
  
  <p>Any pointers to a solution?</p>