Skip to navigationSkip to main contentSkip to footerScaleway DocsSparklesIconAsk our AI
SparklesIconAsk our AI

How to add a trigger to a container

This page shows you how to configure triggers for your Serverless Containers. A trigger is an event that invokes a container.

In a serverless architecture, a container is not running constantly, but is rather activated only when an event occurs. A trigger is a mechanism that connects the container to an event source and enables the container to run automatically in response to specific events.

A trigger can be an HTTP request, a message from a queue or stream, or a CRON schedule. It is configured during the container deployment, and determines how and when the container will run.

Before you start

To complete the actions presented below, you must have:

Queue triggers

InformationOutlineIcon
Note

You must have at least the MessagingAndQueuingReadOnly permission in the Project containing the queue to add a queue trigger to Serverless Containers.

Refer to the permissions sets documentation for more information.

Queue triggers allow you to automatically invoke a container using events stored in a Scaleway queue.

Only queues created with the Scaleway Queues product are compatible with Serverless Containers.

The configuration of the queue retention can affect the behavior of the trigger. Refer to the Considerations to configure event retention for queue trigger inputs page for more information.

AlertCircleIcon

You need to add your queue credentials before creating a queue trigger. To do so:

  1. Create queue credentials
  2. Copy the access key and secret key from the generated credentials
  3. Paste them into the Queue access key and Queue secret key fields when creating your trigger
  1. Click Containers in the Serverless section of the side menu. The containers page displays.
  2. Click the relevant containers namespace.
  3. Click the name of the container you want to manage. The container overview displays.
  4. Click the Triggers tab. The trigger configuration displays.
  5. Click Create trigger. The trigger creation form displays in a pop-up.
  6. Enter a name for your trigger and select the Queues (Scaleway) type, then select your queue name.
  7. Fill in the Queue access key and Queue secret key fields with your credentials.
  8. Click Create trigger to launch the trigger creation.

When a message is pushed to the selected queue, the container will be triggered with the message content passed in the event object's body.

InformationOutlineIcon
Note

Retry Policy: If the Container returns a status code greater than or equal to 300, sending the message will be retried up to three times.

NATS triggers

InformationOutlineIcon
Note

You must have at least the MessagingAndQueuingReadOnly permission in the Project containing the NATS account to add it to a Serverless Container.

Refer to the permissions sets documentation for more information.

NATS triggers allow you to automatically invoke a container using messages sent in a NATS subject.

Scaleway NATS subjects are compatible with Serverless Containers.

AlertCircleIcon

You need to add your NATS credentials before creating a NATS trigger. To do so:

  1. Create NATS credentials
  2. Download the generated credentials file
  3. Copy the content of the file and paste it into the Enter your credentials file content field when creating your trigger

This change was introduced in Serverless Containers API v1, see migration guide.

  1. Click Containers in the Serverless section of the side menu. The containers page displays.
  2. Click the relevant containers namespace.
  3. Click the name of the container you want to manage. The container overview displays.
  4. Click the Triggers tab. The trigger configuration displays.
  5. Click Create trigger. The trigger creation form displays in a pop-up.
  6. Enter a name for your trigger and select the NATS (Scaleway) type, then select your NATS account and subject name.
  7. Paste your NATS credentials in the NATS credentials field.
  8. Click Create trigger to launch the trigger creation.
InformationOutlineIcon
Note

Retry Policy: If the Container returns a status code greater than or equal to 300, sending the message will be retried up to three times.

CRON triggers

CRON triggers allow you to invoke your containers based on a recurring schedule. The CRON triggers for Serverless Containers use the UTC time zone by default, but you can select a different time zone when configuring your trigger.

InformationOutlineIcon
Note

The arguments of a CRON trigger are injected in the body of the HTTP request, and sent to the specified endpoint.

  1. Click Containers in the Serverless section of the side menu. The containers page displays.
  2. Click the relevant containers namespace.
  3. Click the name of the container you want to manage. The container overview displays.
  4. Click the Triggers tab. The trigger configuration displays.
  5. Click Create trigger. The trigger creation form displays in a pop-up.
  6. Enter a name for your trigger and select the CRON type.
  7. Enter the cron schedule in UNIX format.
  8. Select the time zone for your CRON schedule (default is Europe/Paris UTC +2).
  9. Select the HTTP method to use for the request (GET, POST, PUT, DELETE, PATCH, or OPTIONS). Default is POST.
  10. (Optional) Enter a custom HTTP path (for example: /my-trigger) to specify the endpoint to call.
  11. (Optional) Add custom headers to include in the HTTP request.
  12. Paste your JSON arguments.
  13. Click Create trigger to launch the trigger creation.

The container will be invoked at the scheduled time.

InformationOutlineIcon
Note

Refer to the cron schedules reference for more information.

SearchIcon
No Results