我正在学习AWS Lambda。我创建了一个Lambda,将充当REST API(在CloudFormation术语中为APIEvent),并希望使用事件在本地调试该Lambda。
如果我理解正确,运行“sam local generate-event apigateway aws-proxy”会生成适用于本地运行/调试我的Lambda的事件。这将产生以下事件(某些嵌套值已缩写):
如果我理解正确,运行“sam local generate-event apigateway aws-proxy”会生成适用于本地运行/调试我的Lambda的事件。这将产生以下事件(某些嵌套值已缩写):
{
"body": "eyJ0ZXN0IjoiYm9keSJ9",
"resource": "/{proxy+}",
"path": "/path/to/resource",
"httpMethod": "POST",
"isBase64Encoded": true,
"queryStringParameters": {
"foo": "bar"
},
"multiValueQueryStringParameters": {
"foo": [
"bar"
]
},
"pathParameters": {
"proxy": "/path/to/resource"
},
"stageVariables": {
"baz": "qux"
},
"headers": {
...
},
"multiValueHeaders": {
...
},
"requestContext": {
"accountId": "123456789012",
"resourceId": "123456",
"stage": "prod",
"requestId": "c6af9ac6-7b61-11e6-9a41-93e8deadbeef",
"requestTime": "09/Apr/2015:12:34:56 +0000",
"requestTimeEpoch": 1428582896000,
"identity": {
...
},
"path": "/prod/path/to/resource",
"resourcePath": "/{proxy+}",
"httpMethod": "POST",
"apiId": "1234567890",
"protocol": "HTTP/1.1"
}
}
然而,我不理解 resource
(被复制到 requestContext.resourcePath
中)与 path
(被复制到 requestContext.path
中)之间的关系。我应该为这些值填什么?