我已将代码编写为
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
sam-app
Sample SAM Template for sam-app
Globals:
Function:
Timeout: 300
Api:
Cors:
AllowHeaders: "'content-type, authorization'"
AllowOrigin: "'*'"
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello_world
Handler: app.lambda_handler
Runtime: nodejs8.10
Environment:
Variables:
PARAM1: VALUE
Events:
HelloWorld:
Type: Api
Properties:
Path: /hello
Method: get
ApiGateway:
Type: AWS::Serverless::Api
Properties:
StageName: prod
DefinitionBody:
swagger: "2.0"
info:
title:
Ref: AWS::StackName
description: My API that uses custom authorizer
version: 1.0.0
paths:
/hello:
get:
consumes: application/json
produces: application/json
我想将此代码部署到云中
aws cloudformation deploy --template-file output.yaml --stack-name stack1 --parameter-overrides EnvParameter=prod --capabilities CAPABILITY_IAM
然后它说
Failed to create/update the stack. Run the following command
to fetch the list of events leading up to the failure
aws cloudformation describe-stack-events --stack-name stack1
当我评论ApiGateway
代码时,它工作正常。我认为错误可能在代码的下面部分。
ApiGateway:
Type: AWS::Serverless::Api
Properties:
StageName: prod
DefinitionBody:
swagger: "2.0"
info:
title: something
Ref: AWS::StackName
description: My API that uses custom authorizer
version: 1.0.0
paths:
/hello:
get:
consumes: application/json
produces: application/json
请帮我解决这个问题。
谢谢...