Jump toUpdate content

Functions - Quickstart

Published on 26 May 2021

The Scaleway Elements Functions platform makes your functions available, executes them on demand and manages resource allocation for you. 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. We show you how to create a functions namespace, create your function, and delete when no longer needed.

Security & Identity (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
Requirements:

How to create a functions namespace

  1. Click Functions in the Serverless section of the side menu. The functions page displays.

  2. Click Create namespace. The functions namespace creation wizard displays.

  3. Complete the following steps in the wizard:

    • Enter a name and optionally a description for your namespace. The first character of your namespace must be a letter. It can only contain letters, numbers, and dashes. No other special characters are permitted. The namespace is case-sensitive and cannot be edited after its creation.
    • Choose a region, which is the geographical location in which your namespace will be deployed.
    • (Optionally) Enter any environment variables required for your namespace. Environment variables configured in a namespace will be available in all functions/apps within the same namespace. For each environment variable, click +Add and enter the key/value pair.
  4. Click Create namespace to finish.

    Your namespace is now created and you are taken to its Functions tab.

How to create a function

  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 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 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 function to finish.

How to delete a function

  1. Click Functions in the Serverless section of the side menu. The functions page displays.
  2. Click the relevant functions namespace.
  3. Click the «See more Icon» icon next to the function you want to delete, and select Delete from the dropdown menu.
  4. Type DELETE in the pop-up that asks you to confirm the action, then click Delete function.
    Tip:

    You can also delete a function from the Function settings tab.