How do you define a function handler that resides in a directory that's relative to the parent

My use case is this:

  • I want to reference a common handler for a custom authorizer
  • I don’t want the extra expense of maintaining a separate package or git subrepository
  • I don’t want to use symbolic links because that requires extra set up steps for the next developer who uses this repository and also extra documentation
  • I can also install the authorizer in a separate service and then reference it by ARN, but that feels like a “heavier” implementation than it needs to be

I’m trying to define the handler like so:

  auth:
    handler: ../lib/authorize.handler

However, this does not work and results in auth.zip being zero bytes.

If I do something like this:

  auth:
    handler: subfolder/authorize.handler

It will work as expected.

Is this an inherent limitation in the Serverless Framework or am I just overlooking something really simple?

Incidentally, I am using serverless 1.29.0 with the serverless-webpack plugin 5.20.0.

2 Likes

Did you ever figure this out? I’m experimenting referencing a handler function from a parent directory as well and not making much progress

Unfortunately, I did not. I just "brute force"d it, by using symbolic links. I haven’t gone back to figure out if serverless supports this type of use case now, but maybe because of your post, this thread will get bumped, and we can get an answer.

Doesn’t have solution for this yet?

I am expecting to do the same,I used symbolic link but that cause me an error which say:

Resource handler returned message: “Unzipped size must be smaller than 55046686 bytes (Service: Lambda, Status Code: 400, Request ID: 160800aa-7040-4699-a22a-36c1cb91ed89)” (RequestToken: eb9a6882-d0ca-fe7c-7617-8ab39e1b749f, HandlerErrorCode: InvalidRequest)