79494743

Date: 2025-03-08 17:19:22
Score: 0.5
Natty:
Report link

Yes the SAM CLI can be used to develop lambda authorizers with caveats. The SAM CLI was created for developing general purpose Lambda functions -- not authorizers. Because of this not all SAM features are usable for authorizer development. Also, SAM commands that do work may output spurious errors. Specifically this behavior is due to the fact that authorizers have different input parameters (events) and return values than general purpose Lambda functions.

Hear is how to work around these differences:

  1. The example event in the "events" folder will need to be replaced by an appropriate event type for the specific configuration of API Gateway you are using. There are three different event schemas:

    1. HTTP API Gateway Version 1, REST API Gateway Request Authorization

    2. HTTP API Gateway Version 2

    3. REST API Gateway Token Authorization

  2. Running a local server with the "sam local start-api" command does not work. This is because the event that start-api composes is not the appropriate type for an authorizer.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Johnny Petro