Serverless::Function中Api事件的RequestParameters - 它是如何工作的?

0

【以下的问题经过翻译处理】 我正在尝试使用SAM模板中的JSON编写添加一些查询字符串参数到一个Lambda函数。所有的示例都是使用YAML编写的?有人能指出我哪里出错了吗?

这是定义的片段:

    "AreaGet": {
      "Type": "AWS::Serverless::Function",
      "Properties": {
        "Handler": "SpeciesRecordLambda::SpeciesRecordLambda.Functions::AreaGet",
        "Runtime": "dotnet6",
        "CodeUri": "",
        "MemorySize": 256,
        "Timeout": 30,
        "Role": null,
        "Policies": [
          "AWSLambdaBasicExecutionRole"
        ],
        "Events": {
          "AreaGet": {
            "Type": "Api",
            "Properties": {
              "Path": "/",
              "Method": "GET",
              "RequestParameters": [
                "method.request.querystring.latlonl": {
                  "Required": "true"
                },
                "method.request.querystring.latlonr": {
                  "Required": "true"
                }
              ]
            }
          }
        }
      }
    },

这是我得到的错误消息:

Failed to create CloudFormation change set: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [AreaGet] is invalid. Event with id [AreaGet] is invalid. Invalid value for 'RequestParameters' property. Keys must be in the format 'method.request.[querystring|path|header].{value}', e.g 'method.request.header.Authorization'.

profile picture
专家
已提问 5 个月前38 查看次数
1 回答
0

【以下的回答经过翻译处理】 如果你像下面这样用 {} 包含数组的元素,它能正常工作吗?

"Events": {
    "AreaGet": {
        "Type": "Api",
        "Properties": {
            "Path": "/",
            "Method": "GET",
            "RequestParameters": [
                {
                    "method.request.querystring.latlonl": {
                        "Required": "true"
                    }
                },
                {
                    "method.request.querystring.latlonr": {
                        "Required": "true"
                    }
                }
            ]
        }
    }
}

profile picture
专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则