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
EXPERTE
gefragt vor 5 Monaten42 Aufrufe
1 Antwort
0

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

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

profile picture
EXPERTE
beantwortet vor 5 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen