Control ZIP file folder structure


#1

I am using serverless 1.4.0 and have my handler.js file under a src folder. When I deploy and then look at the ZIP file under the .serverless folder the folder structure inside the ZIP includes the src folder. Is there a way so that the contents of the src folder will be at the root level inside the ZIP and not have src be at the root level?


#2

No, not at the moment. Changing the location of the handler file at deploy time would mean that the handler function reference in your serverless.yml would need to be changed too.

What’s the benefit you’re after? Why not just put your serverless.yml in your src/ folder too? Then all of your src/ will be the top-level of your service.


#3

Moving the serverless.yml file inside the src folder was what I needed to do. Thank you.


#4

For packaging it would be nice if we could specify the target location in side the ZIP location.

I have a similar project setup and just to keep the project clean I really wanted to keep my source code in src and my serverless.yaml at the root of the repo.

It’s also required if you are using python with a virtual environment because lambda requires copying the pip dependencies from $VIRTUAL_ENV/lib/python2.7/site-packages to the root of the zip file. See some docs here..