Update content

How to create a function

Published on 26 May 2021

This page shows you how to deploy your first Scaleway Function. A function is a lightweight unit of logic, defining a procedure for changing one element into another. The function remains static, while the variables that pass through it can vary. The Scaleway Functions platform makes your function available, executes it on demand and manages resource allocation for you.

Identity and Access Management (IAM):

If you have activated IAM, you may need certain IAM permissions to carry out some actions described on this page. This means:

  • you are the Owner of the Scaleway Organization in which the actions will be carried out, or
  • you are an IAM user of the Organization, with a policy granting you the necessary permission sets
  1. Click Functions in the Serverless section of the side menu. The functions page displays.
  2. Click the functions namespace you want to use to create your function.
  3. Click Create a function. The function creation wizard displays.
  4. Complete the following steps in the wizard:
    • Enter your function code.
      • From the first drop-down menu, choose to either use the inline code editor to edit your code directly from your browser in the box provided, or to upload a *.zip archive.
      • From the second drop-down menu, choose your desired runtime, e.g. node16, node18, python37, python310 or go118.
      • From the third drop-down menu, set the Handler for your function
    • Choose a name for your function, and optionally a description. The name must only contain alphanumeric characters.
    • Choose the resources to be allocated to your function at runtime. These define the performance characteristics of your function.
    • Set your scaling preferences, or leave them at default values. The Scaleway platform autoscales the number of available instances of your function to match the incoming load, depending on the settings you define here.
    • Define any environment variables you want to inject into your function. For each environment variable, click +Add and enter the key/value pair.
    • Set secret environment variables (optional). Secrets are environment variables which are injected into your function and stored securely, but not displayed in the console after initial validation. Add a key and a value.
    • Set the desired privacy policy for your function. This defines whether a function can be executed anonymously (public) or only via an authentication mechanism provided by the Scaleway API (private).
    • Optionally, use the advanced options to add triggers to your function deployment. Adding triggers enables the function to handle events coming from sources other than an HTTP endpoint, such as CRON (time-based jobs).
    • Verify the estimated cost.
  5. Click Create a function to finish.
See Also