How to package your function to a zip file and upload it
This page explains how to upload your functions and their dependencies as a zip file using the Scaleway console.
This feature allows you to add your libraries or static files to your function.
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- A functions namespace
- installed jq
How to package a function into zip file
There are different methods to deploy functions and some of them require the function to be packaged into a zip
file.
To match the Scaleway build pipelines requirements, functions zip files must contain the content of the root folder you want to publish.
How to create a zip file
Use the zip
command to create an archive of your function and its dependencies:
zip -r myFunction.zip myFunction/
The example above will create a .zip
archive that contains the myFunction folder and its content. You can then upload this archive to your Serverless Functions.
How to upload your zip file
How to configure your package
Handler
Dependencies
How to manage multiple handles in the same zip file
To enhance deployment simplicity, all runtimes support the inclusion of multiple handlers, either within a single file or across multiple files.
Example:
.
├── myFuncA.lang (contains handlerA() and handlerB())
└── myFuncB.lang (contains handlerC())
Like that, you can create 3 functions with the same zip file simply by changing the handler parameter to match the handler you want:
myFuncA.handlerA
myFuncA.handlerB
myFuncB.handlerC
You can also create a single Serverless Function with several handlers in the same zip file, and change the handler parameter according to your needs.
Troubleshooting
If you encounter build errors after packaging your function, make sure that your archive is properly structured, as shown above. Compressing a folder from its parent directory will include this folder in the archive structure that can lead to build errors while deploying your function.
To avoid archive structure issue, make sure to zip your function from its root folder, and not the parent directory by using the following method:
cd folder_i_want_to_zip
zip -r ../function.zip .
You can then use the unzip
command with the -v
option to list the content of your archive to ensure it is properly structured:
unzip -v ../func.zip