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.
However, the following deployment fails:
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
The error message is the following:
The REST API doesn't contain any methods (Service: AmazonApiGateway;
Status Code: 400; Error Code: BadRequestException
Looking on Google, I do find mentions of this error when manually specifying a deployment (here, or here). In my case, the deployment is implicit, hence I assume my issue is different.
The code I'm using is based on a SAM example (here). I'm scratching my head to understand what is wrong with my stack.
Any pointers to a solution?