Description
I have rewritten the issue using your examples instead of my implementation to help with reproducibility.
Hi, I have been trying to write a simple Lambda function in Rust with the Function URL according to one of your examples here.
Testing the Lambda locally with cargo lambda
correctly returns Command do something executed.
cargo lambda invoke something --data-ascii '{ "command": "do something" }'
There were no issues when executing the Lamba Test Event in the web GUI either. The problem only comes after deployment. Sending the exact POST request with Insomnia always returns an InternalServerError. CloudWatch complains of the following.
ERROR Lambda runtime invoke{requestId="5fb1fd9b-e8cd-48a4-b641-caf1ff16529b" xrayTraceId="Root=1-63e9481d-6db35e9e5220a0d061dd7904;Parent=0d074a1c13e2a3e8;Sampled=0"}: lambda_runtime: Error("missing field `command`", line: 1, column: 1118)
Okay fine, so I tried the example written in the lambda-http
documentation here. I tested this again with Insomnia and CloudWatch now complains of the following.
thread 'main' panicked at 'called Option::unwrap() on a None value'
At this point, I was getting pretty desperate and did a fresh generation of cargo lambda new
with the Function URL template selected. Unsurprisingly, this was just an exact copy of your http-basic-lambda
example here. I did the same test with cargo lambda invoke
as above and this time it returned the following.
Error: serde_json::error::Error
× data did not match any variant of untagged enum LambdaRequest
This is my Cargo.toml.
[dependencies]
tokio = { version = "^1.25.0", features = ["macros"] }
reqwest = { version = "^0.11.14", default-features = false, features = ["json", "rustls-tls"] }
lambda_http = { version = "^0.7.3", default-features = false, features = ["apigw_http"] }
tracing-subscriber = { version = "^0.3", default-features = false, features = ["fmt"] }
tracing = { version = "^0.1", features = ["log"] }
serde = { version = "^1.0.152", features = ["derive"] }
serde_json = "^1.0.93"
futures = "^0.3.26"