Closed biajoeknee closed 2 years ago
Resolved the issue. I assumed that the runtime would also work with a AWS REST API Gateway. I already had one up and running when I began the Swift Lambda Runtime tutorial, so I linked one of the endpoints to the Swift Lambda instead of creating a new HTTP API Gateway. The Lambda ran, but was not provided the APIGateway.V2.Request
object; it has to be provided by the caller, apparently in its entirety.
I eventually ended up creating a HTTP API Gateway, and trying it that way; and just like in the tutorial, I didn't have to provide the entire APIGateway.V2.Request
object in the request payload, just the body.
Expected behavior
I expected that I would be able to make a POST request with the payload "{ "number": 3 }" (from tutorial), and AWS would create the
APIGateway.V2.Request
object for me, storing the payload in theAPIGateway.V2.Request.body
property.Actual behavior
It's as if the Lambda is expecting the consumer of the API to provide all the
APIGateway.V2.Request
properties in the payload. The specific error I got when attempting to call the Lambda is:If I provide values for all the
APIGateway.V2.Request
properties, then the Lambda works as expected: Successful payload:Response:
Steps to reproduce
If possible, minimal yet complete reproducer code (or URL to code)
Here is the code in my main file:
Here is my package.swift:
SwiftAWSLambdaRuntime version/commit hash
0.5.2
Swift & OS version (output of
swift --version && uname -a
)Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28) Target: x86_64-apple-darwin19.5.0 Darwin My-MBP-2.local 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64