I'm trying to create a custom ApiGatewayV2 authorizer lambda for a WebSocket API using ApiGatewayV2CustomAuthorizerV1Request or ApiGatewayV2CustomAuthorizerV2Request, but the lambda fails to run in both cases.
It runs the main() function with no issues, but code inside the handler_fn is being completely ignored, and no error whatsoever is being thrown. I've tried using other types, such as ApiGatewayCustomAuthorizerRequest, and they work just fine, but they're incompatible with the API Gateway version and return incorrect/missing data.
Sometimes it outputs an "Unknown.Runtime" error message directly in the lambda logs.
I'm using lambda_runtime and aws_lambda_events, both v0.7.0.
I've tried v0.7.1 and v0.7.2 and had the exact same result.
Here's the code:
use aws_lambda_events::apigw::ApiGatewayV2CustomAuthorizerV2Request;
use lambda_runtime::{service_fn, Error, LambdaEvent};
#[tokio::main]
async fn main() -> Result<(), Error> {
println!("Running main function");
let handler = service_fn(|event| handler_fn(event));
lambda_runtime::run(handler).await?;
println!("Finished running");
Ok(())
}
async fn handler_fn(
event: LambdaEvent<ApiGatewayV2CustomAuthorizerV2Request>,
) -> Result<ApiGatewayV2CustomAuthorizerV2Request, Error> {
println!("Query params:");
println!("{:#?}", event.payload.query_string_parameters);
Ok(event.payload)
}
Here are the lambda logs:
2023-01-05T20:53:34.722-03:00 | Running main function
2023-01-05T20:53:34.729-03:00 | START RequestId: e320b0aa-6596-4396-abb5-2989ebfad615 Version: $LATEST
2023-01-05T20:53:34.731-03:00 | END RequestId: e320b0aa-6596-4396-abb5-2989ebfad615
2023-01-05T20:53:34.731-03:00 | REPORT RequestId: e320b0aa-6596-4396-abb5-2989ebfad615 Duration: 1.57 ms Billed
And here's my lambda configuration:


Also, what's the difference between ApiGatewayV2CustomAuthorizerV1Request and ApiGatewayV2CustomAuthorizerV2Request?
Thanks!