amazon-web-servicesaws-lambdaaws-api-gatewaylambda-authorizer

How to view print logs for AWS API Gateway V2 Custom Authorizor?


I have a lambda that is hooked up to my API Gateway to trigger when a GET /resource request is made. I validated that this is working before adding the authorizer.

I then added the following authorizer and hooked it up to my API Gateway: enter image description here

I can make a request now and I see:

{
    "message": "Unauthorized"
}

This is expected, but I cannot find logs anywhere to show me what's happening in my authorizer lambda so that I can debug and further implement my authorizer.

I looked around and while there is access logging that shows some information from API Gateway about the authorization invocation, there isn't anything that will create CloudWatch Logs for the authorizer itself.

I would like to take a peek into what's happening in my authorizer during runtime, how would I do this?


Solution

  • Turns out that API Gateway requires your identity source to but non-empty, in my case, it was headers.Authorization.

    If this value is empty, it won't even try to invoke the authorizer, it'll just respond with a 401.

    After providing a value, my authorizer lambda was invoked and a new message was returned (403):

    {
        "message": "Forbidden"
    }
    

    Note that this is configured to use the simple response payload so a true/false is returned for isAuthorized.