SAM模板“无效的模板属性或[MyApi]属性”

时间:2019-03-07 04:36:16

标签: aws-lambda aws-serverless aws-sam aws-sam-cli

运行CLI命令aws cloudformation deploy(在sam软件包之后)后,出现以下错误

“无法创建变更集:服务员ChangeSetCreateComplete失败:服务员遇到终端失败状态:状态:失败。原因:无效的模板属性[MyApi]”

这是模板。我无法获得有关哪个是无效属性的信息。这可能吗?否则此模板有什么问题?

AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31

Resources:
  HelloFunction:
    Type: AWS::Serverless::Function
    Properties:`enter code here`
      Handler: main
      Runtime: go1.x
      Events:
        GetEvent:
          Type: Api
          Properties:
            Path: /
            Method: post
            #RestApiId: !Ref ApiGateway1

  LambdaInvokePermission:
    Type: AWS::Lambda::Permission
    Properties:
      FunctionName: !GetAtt
        - HelloFunction
        - Arn
      Action: 'lambda:InvokeFunction'
      Principal: apigateway.amazonaws.com
      SourceAccount: !Ref 'AWS::AccountId'

MyApi:
  Type: AWS::Serverless::Api
  Properties:
    StageName: default
    EndpointConfiguration: REGIONAL
    DefinitionBody:
      swagger: "2.0"
      info:
        title: "TestAPI"
      paths:
        /:
          get:
#            parameters:
#              - name: "id"
#                in: "query"
#                required: true
#                type: "string"
#            x-amazon-apigateway-request-validator: "Validate query string parameters and\
#                \ headers"
            x-amazon-apigateway-integration:
              uri:
                Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HelloFunction.Arn}/invocations
              responses: {}
              httpMethod: "POST"
              type: "aws_proxy"



Outputs:
  FunctioArn:
    Value: !GetAtt  HelloFunction.Arn
    Export:
      Name: HelloFunctionArn

1 个答案:

答案 0 :(得分:2)

MyApi出现缩进错误。使用以下内容:

/*
int a = 20;
  /*
   int b = 10;

  */ 
*/