Uploading with the Serverless.com framework

Jump toUpdate content

Uploading functions using the Serverless.com framework

Reviewed on 20 December 2021Published on 26 May 2021

The Scaleway functions plugin for Serverless Framework allows users to deploy their functions and containers to Scaleway Serverless with a simple serverless deploy.

Serverless Framework handles everything from creating namespaces to function/code deployment by calling APIs endpoint under the hood.


Creating a project folder

Serverless Framework enables you to create a project using a specific template.

  1. Create the following directory: ~/my-srvless-projects. Then, change into it.

    mkdir ~/my-srvless-projects
    cd ~/my-srvless-projects
  2. Create a simple Python 3 template:

    serverless create --template-url https://github.com/scaleway/serverless-scaleway-functions/tree/master/examples/python3 --path myService

    You can find other Scaleway templates on the Scaleway Serverless GitHub page.

Editing the serverless.yml file


Do not edit the provider.name and plugins parameters, as these allow you to use the Scaleway provider.

The serverless.yml file contains the configuration of a namespace containing one or more functions with the same runtime. In the following example, we use one function and a python3 runtime.

The different parameters are:

  • service: your namespace name
  • provider.runtime: the runtime of your functions (check the supported runtimes above)
  • provider.env: the environment variables attached to your namespace are injected into all your namespace containers
  • scwToken: the Scaleway token you got in prerequisites
  • scwProject: the Scaleway Project ID
  • package.patterns: usually, this parameter does not need to be configured. It allows you to include or exclude directories from the deployment
  • functions: Configuration of your functions. It is a yml dictionary, with the key being the functions’ name
    • handler (Required): file or function which will be executed.
    • env (Optional): environment variables specifics for the current function
    • minScale (Optional): how many function instances we keep running (default: 0)
    • maxScale (Optional): maximum number of instances this function can scale to (default: 20)
    • memoryLimit: RAM allocated to the function instances.
    • runtime: (Optional) runtime of the function. Can be used when you need to deploy multiple functions with different runtimes in your Serverless Project. If absent, provider.runtime will be used.
    • events (Optional): List of events that trigger your functions (e.g, trigger a function based on a schedule with CRONJobs).

Configuring your Functions Handler

Based on the chosen runtime, the handler variable in the function might vary.


For more detail on how to package your dependencies please refer to How to package your function and upload it as a Zip.


  1. Path to your handler file (from serverless.yml), omit ./, ../, and add the exported function to use as a handler:
# ls
- src
- handlers
- firstHandler.js => module.exports.myFirstHandler = ...
- secondHandler.js => module.exports.mySecondHandler = ...
- serverless.yml
  1. In the serverless.yml file, launch:
# ...
runtime: node16 # or node14, ...
handler: src/handlers/firstHandler.myFirstHandler
handler: src/handlers/secondHandler.mySecondHandler
  1. Include the node_modules folder in your package list to add dependencies to your function.
- '!.gitignore'
- '!.git/**'
- './node_modules/**'


  1. Path to the handler file src/testing/handler.py:
- src
- handlers
- firstHandler.py => def my_first_handler
- secondHandler.py => def my_second_handler
- serverless.yml
  1. Launch in serverless.yml:
# ...
runtime: python3 # or python for python 2.7
handler: src/handlers/firstHandler.my_first_handler
handler: src/handlers/secondHandler.my_second_handler


If you have the following structure, the path to your handler’s package should resemble the following:

- src
- testing
- handler.go -> package main in src/testing subdirectory
- second
- handler.go -> package main in src/second subdirectory
- serverless.yml
- handler.go -> package main at the root of project

Your serverless.yml functions should be similar to:

# ...
runtime: go118
handler: "."
handler: src/testing
handler: src/second

Configuring events

With events, you may link your containers to specific triggers. For the moment, the feature is limited to CRON Schedule (time-based).


We do not include HTTP triggers in our event types, as an HTTP endpoint is created for every function. Triggers are just another way to trigger your functions, but you will always be able to execute your code via HTTP.

Below is a list of supported triggers for Scaleway Serverless, and the configuration parameters required to deploy them:

  • schedule: Triggers your container based on CRON schedules
    • rate: the CRON Schedule (UNIX Format) on which your functions will be executed
    • input: key-value mapping to define arguments that will be passed to your function’s event object during execution

To link a Trigger to your function, you can define an events key in your function:

handler: myHandler.handle
# "events" is a list of triggers, the first key being the type of trigger.
- schedule:
# CRON Job Schedule (UNIX Format)
rate: '1 * * * *'
# Input variable are passed in your function's event during execution
key: value
key2: value2

You can find other examples of trigger configurations on the Scaleway Serverless Github page.

Accessing Logs

The serverless logs command allows you to watch the logs of a specific function. Add the --function option and the function’s name to the serverless logs command to fetch the logs of a specific container.

serverless logs --function <function_name>`

Deleting a project

Run the following command to remove a project:

serverless remove

This removes all your functions, as well as your Scaleway Functions’ namespace.

Note: Your Scaleway Functions Registry namespace is not automatically removed. You must delete it manually either via the Scaleway console, or Scaleway's Functions Registry API.
See Also