rustaws-lambdaamazon-cognitoaws-cdkaws-rest-api

AWS RestAPI does not forward Cognito Auth Information to Lambda function


as the title already implies my RestAPI does not forward the user information of the authorized client to my lambda function. I tried with a rust lambda function (see the issue here), but it turned out, a nodejs implementation has the same problem. I have posted my cdk setup in the above issue and i bet there is a configuration mistake i made, but just cannot find.

I checked that you need to be authroized in the first place (which works, as the gateway returns "unauthorized" in that case). But whatever i tried so far, the context.identity field is always empty/null.

Any help appreciated!


Solution

  • The user identity in the above mentioned use case can be found in the request_context, not lambda_context.

    match request.request_context() {
        RequestContext::ApiGatewayV1(context) => {
            println!("{:?}", context.identity);
        }
    }