|
9 | 9 | validation: 2025-06-23 |
10 | 10 | posted: 2025-06-13 |
11 | 11 | --- |
12 | | -import Requirements from '@macros/iam/requirements.mdx' |
13 | 12 |
|
| 13 | +import AutomateResourcesManagement from '@macros/serverless-jobs/automate-resources-management.mdx' |
14 | 14 |
|
15 | | -[Scaleway Serverless Jobs](/serverless-jobs/quickstart/) allows you to create and automate recurring tasks. This page shows how to create jobs to perform any operation available with the [Scaleway CLI](https://github.com/scaleway/scaleway-cli/blob/master/docs/commands/config.md) to automate the management of your Scaleway resources. |
16 | | - |
17 | | -Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not need autoscaling or exposure via a web server. Refer to the [documentation on differences between jobs, containers, and functions](/serverless-jobs/reference-content/difference-jobs-functions-containers/) for more information. |
18 | | - |
19 | | -<Requirements /> |
20 | | - |
21 | | -- A Scaleway account logged into the [console](https://console.scaleway.com). |
22 | | -- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization. |
23 | | - |
24 | | -## Creating the job definition |
25 | | - |
26 | | -1. In the [Scaleway console](https://console.scaleway.com), click **Jobs** in the **Serverless** section of the side menu. The jobs page displays. |
27 | | - |
28 | | -2. Click **Create job**. The job creation wizard displays. |
29 | | - |
30 | | -3. For **Container Image**, select **External**, and in **Image URL**, set: `scaleway/cli:latest`. |
31 | | - |
32 | | -4. Enter a name or use the automatically generated one. |
33 | | - |
34 | | -5. Select the region in which your job will be created. |
35 | | - |
36 | | -6. Keep the default **resources** values, as this job requires little compute capability. |
37 | | - |
38 | | -7. Set a **cron schedule** in the `* * * * *` format (such as `0 0 * * *` to run the job every day at midnight), and select the relevant time zone to run the job at the desired frequency. Refer to the [cron schedules documentation](/serverless-jobs/reference-content/cron-schedules/) for more information. |
39 | | - |
40 | | -8. Define the following environment variables: |
41 | | - - `SCW_ACCESS_KEY`: your API access key. |
42 | | - - `SCW_SECRET_KEY`: your API secret key. |
43 | | - - `SCW_DEFAULT_PROJECT_ID`: your Project ID. |
44 | | - - `SCW_DEFAULT_ORGANIZATION_ID`: your Organization ID. |
45 | | - - `SCW_DEFAULT_REGION`: desired region. |
46 | | - |
47 | | - <Message type="note"> |
48 | | - We recommend using [Secret Manager](/secret-manager/quickstart/) to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`. |
49 | | - </Message> |
50 | | - |
51 | | - For more details about variables used by `cli`, refer to the [CLI config documentation](https://github.com/scaleway/scaleway-cli/blob/master/docs/commands/config.md). |
52 | | - |
53 | | -9. In the **Execution** tab, define the desired Scaleway CLI command, as shown in the examples below: |
54 | | - - **Power on and off Instances** |
55 | | - ```sh |
56 | | - # Power on |
57 | | - /scw instance server start 11111111-1111-1111-1111-111111111111 |
58 | | - |
59 | | - # Power off |
60 | | - /scw instance server stop 11111111-1111-1111-1111-111111111111 |
61 | | - ``` |
62 | | - - **Create a snapshot of an Instance volume** |
63 | | - ```sh |
64 | | - /scw instance snapshot create volume-id=11111111-1111-1111-1111-111111111111 |
65 | | - ``` |
66 | | - - **Create a backup of an Instance** |
67 | | - ```sh |
68 | | - /scw instance server backup 11111111-1111-1111-1111-111111111111 |
69 | | - ``` |
70 | | -10. Click **Create job**. |
71 | | - |
72 | | -Your Serverless Job will run the command periodically according to the [cron schedule](/serverless-jobs/reference-content/cron-schedules/) you defined. |
73 | | - |
74 | | -## Running the job |
75 | | - |
76 | | -From the **Overview** tab of the Serverless job you just created, click **Actions**, then select **Run job** from the contextual menu. |
77 | | - |
78 | | -The execution appears in the **Job runs** section. You can access the logs of your job by clicking <Icon name="more" /> next to the job run ID, and selecting **See on Cockpit**. |
| 15 | +<AutomateResourcesManagement /> |
0 commit comments