I'm able to define and deploy my API Gateway + Lambda stack using Cloudformation / Serverless Application Model, an want to add a model to my API.
I've created the model in YAML, but it appears to be unable to reference the API defined in the Outputs
section of my file.
The error I see is
Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED.
Reason: Template format error: Unresolved resource dependencies [MyApi] in the Resources block of the template
Is it possible to reference the Output
object, or is it not considered a Resource in this context? i.e. do I need to explicitly define an AWS::Serverless::Api
instead of using the Output
?
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
PutItemFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: put_item
Handler: handlers.put_item
Runtime: python3.6
Events:
PutResource:
Type: Api
Properties:
Path: /
Method: put
ModelResource:
Type: AWS::ApiGateway::Model
Properties:
RestApiId:
Ref: MyApi
ContentType: "application/json"
Name: MyModel
Schema:
"$schema": "http://json-schema.org/draft-04/schema#"
type: object
properties:
id:
type: string
Outputs:
MyApi:
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/s/"