NavigationContentFooter
Jump toSuggest an edit

How to add a trigger to a container

Reviewed on 04 October 2023Published on 27 April 2023

This page shows you how to configure triggers for your containers. A trigger is an event that invokes a Serverless Container. In a serverless architecture, a container is not running constantly, but is rather activated only when there is an event. 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. The trigger can be an HTTP request, a message from a queue or stream, a CRON schedule etc.

The trigger is configured during the container deployment, and it determines how and when the container will run.

Requirements
  • You have an account and are logged into the Scaleway console
  • You have created a containers namespace
  • You have deployed a container from Scaleway Container Registry or an external registry
  • You have activated SQS
  • You have created credentials for SQS
  • You have created an SQS queue
Important

You can create triggers on private functions, but to update the privacy of a function from public to private, you must recreate the existing SQS and NATS triggers after the privacy change. We are actively working to make this operation as seamless as possible.

Note

Triggers send messages through a POST request with the message body in the request body.

SQS triggers

An SQS (Simple Queue Service) trigger is a mechanism that connects a container to an SQS queue and invokes the container automatically whenever a message is added to the queue. For each message that is sent to an SQS queue, the SQS trigger reads the message and invokes the associated container with the message as the input parameter. The containerized application can then process the message and perform any required actions, such as updating a database or sending a notification. Currently, SQS queues of the Scaleway Messaging and Queuing product are supported.

The configuration of the queue retention may affect the behavior of the 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 SQS (Scaleway) type, then select your queue name.
  7. Click Create trigger to launch the trigger creation.

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

NATS triggers

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

NATS subjects of the Scaleway Messaging and Queuing product are compatible with Serverless Containers.

  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. Click Create trigger to launch the trigger creation.

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.

  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. Enter the cron schedule in UNIX format and paste your JSON arguments in the form.
  7. Click Create trigger to launch the trigger creation.

The container will be invoked at the indicated time.

Note

Refer to our cron schedules reference for more information.

How to secure a containerHow to delete a container
Cloud Products & Resources
  • Scaleway Console
  • Compute
  • Storage
  • Network
  • IoT
  • AI
Dedicated Products & Resources
  • Dedibox Console
  • Dedibox Servers
  • Network
  • Web Hosting
Scaleway
  • Scaleway.com
  • Blog
  • Careers
  • Scaleway Learning
Follow us
FacebookTwitterSlackInstagramLinkedin
ContractsLegal NoticePrivacy PolicyCookie PolicyDocumentation license
© 1999-2024 – Scaleway SAS