How to add a trigger to a function
This page shows you how to configure triggers for your functions. Triggers are configured during function deployment, and determine how and when the function will execute.
- You have an account and are logged into the Scaleway console
- You have created a functions namespace
- You have created a function
- You have activated SQS
- You have created credentials for SQS
- You have created an SQS queue
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.
Triggers send messages through a POST
request with the message body in the request body.
SQS triggers
SQS triggers allow you to automatically invoke a function using events stored in a queue.
SQS queues of the Scaleway Messaging and Queuing product are compatible with Serverless Functions.
The configuration of the queue retention may affect the behavior of the trigger. Refer to the Considerations to configure event retention for SQS trigger inputs page for more information.
- Click Functions in the Serverless section of the side menu. The functions page displays.
- Click the relevant functions namespace.
- Click the name of the function you want to manage. The function 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 SQS (Scaleway) type, then select your queue name.
- Click Create trigger to launch trigger creation.
NATS triggers
NATS triggers allow you to automatically invoke a function using messages sent in a NATS subject.
NATS subjects of the Scaleway Messaging and Queuing product are compatible with Serverless Functions.
- Click Functions in the Serverless section of the side menu. The functions page displays.
- Click the relevant functions namespace.
- Click the name of the function you want to manage. The function 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 trigger creation.
CRON triggers
CRON triggers allow you to invoke your functions based on a recurring schedule.
- Click Functions in the Serverless section of the side menu. The functions page displays.
- Click the relevant functions namespace.
- Click the name of the function you want to manage. The function 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 trigger creation.