You can create triggers on private containers, but to update the privacy of a container from public to private, you must recreate the existing Scaleway Queues and Scaleway NATS triggers after the privacy change. We are actively working to make this operation as seamless as possible.
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, a CRON schedule etc. 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:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- Created a containers namespace
- Deployed a container from Scaleway Container Registry or an external registry
- Created credentials for Scaleway Queues
- Created a queue
Triggers send messages through a POST
request with the message body in the request body.
Queue triggers
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.
- Click Containers in the Serverless section of the side menu. The containers page displays.
- Click the relevant containers namespace.
- Click the name of the container you want to manage. The container overview displays.
- Click the Triggers tab. The trigger configuration displays.
- Click Create trigger. The trigger creation form displays in a pop-up.
- Enter a name for your trigger and select the Queues (Scaleway) type, then select your queue name.
- 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.
Scaleway NATS subjects are compatible with Serverless Containers.
- Click Containers in the Serverless section of the side menu. The containers page displays.
- Click the relevant containers namespace.
- Click the name of the container you want to manage. The container overview displays.
- Click the Triggers tab. The trigger configuration displays.
- Click Create trigger. The trigger creation form displays in a pop-up.
- Enter a name for your trigger and select the NATS (Scaleway) type, then select your NATS account and subject name.
- 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.
- Click Containers in the Serverless section of the side menu. The containers page displays.
- Click the relevant containers namespace.
- Click the name of the container you want to manage. The container overview displays.
- Click the Triggers tab. The trigger configuration displays.
- Click Create trigger. The trigger creation form displays in a pop-up.
- 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.
- Click Create trigger to launch the trigger creation.
The container will be invoked at the indicated time.
Refer to the cron schedules reference for more information.