This example demonstrates how to set up a Scaleway Serverless Job using Terraform.
It builds a custom image locally, pushes this to the Scaleway registry, then creates a job that runs this image on a schedule.
This example assumes you are familiar with how Serverless Jobs work. If needed, you can check Scaleway's official documentation
This example uses Terraform. Please set up your local environment as outlined in the docs for the Scaleway Terraform Provider.
You will also need a Scaleway API key, which can be configured using Scaleway IAM. If you are using IAM policies, make sure the key has the permissions: ServerlessJobsFullAccess
, ContainerRegistryFullAccess
.
Once your environment is set up, you need to export some environment variables to use your API key:
export TF_VAR_access_key=<your api key>
export TF_VAR_secret_key=<your secret key>
export TF_VAR_project_id=<your project ID>
From there, you can run the following to set up your job:
cd terraform
terraform init
terraform plan
terraform apply
You can then view your Job Definitions in the Scaleway Console.
The Job is set to run on a schedule, once every 5 minutes. Once the next schedule has run, you will see a "Job Run" listed for your Job Definition.
Note this job will keep running every 5 minutes, so you need to make sure you delete the job by running:
cd terraform
terraform destroy