验证错误 ApiGatewayMethodProxyVarGet:预期类型:Boolean,发现:AWS CloudFormation 中的 JSONObject

问题描述 投票:0回答:1

我正在尝试使用无服务器部署到 lambda,但它在 cloudformation 堆栈中失败。

下面是cloudformation模板“ApiGatewayMethodProxyVarGet”部分

"ApiGatewayMethodProxyVarGet": 
{
  "Type": "AWS::ApiGateway::Method",
  "Properties": {
    "HttpMethod": "GET",
    "RequestParameters": {},
    "ResourceId": {
      "Ref": "ApiGatewayResourceProxyVar"
    },
    "RestApiId": {
      "Ref": "ApiGatewayRestApi"
    },
    "ApiKeyRequired": false,
    "AuthorizationType": "NONE",
    "Integration": {
      "IntegrationHttpMethod": "POST",
      "Type": "AWS_PROXY",
      "Uri": {
        "Fn::Join": [
          "",
          [
            "arn:",
            {
              "Ref": "AWS::Partition"
            },
            ":apigateway:",
            {
              "Ref": "AWS::Region"
            },
            ":lambda:path/2015-03-31/functions/",
            {
              "Fn::GetAtt": [
                "HttpLambdaFunction",
                "Arn"
              ]
            },
            "/invocations"
          ]
        ]
      }
    },
    "MethodResponses": []
  },
  "DependsOn": [
    "HttpLambdaPermissionApiGateway"
  ]
}

有人可以把我引向正确的方向吗?

干杯!

amazon-web-services aws-lambda aws-cloudformation aws-api-gateway serverless
1个回答
0
投票

根据您发送的模板,似乎缺少某些内容,或者您正在通过 SAM 之类的东西运行它,这会更改某些属性。该错误表明您的代码具有以下内容:

"RequestParameters": {
  "method.request.path.proxy": { "Key": "Value"}
},

该资源的架构定义了如下值:

"RequestParameters": {
   "additionalProperties": false,
   "patternProperties": {
    "[a-zA-Z0-9]+": {
     "type": [
      "boolean",
      "string"
     ]
    }
   },
   "type": "object"
  },

这意味着

method.request.path.proxy
的值应该是布尔值。它还允许字符串,只要该字符串的值为布尔值“true”

© www.soinside.com 2019 - 2024. All rights reserved.