Skip to content

Commit 2681b00

Browse files
docs(srv): how to automate scw resource mgmt w/ jobs MTA-6074 (#5115)
* docs(srv): how to automate scw resource mgmt w/ jobs MTA-6074 * docs(srv): update * docs(srv): update * docs(srv): update * docs(srv): update * docs(srv): update * Update pages/serverless-jobs/how-to/automate-resources-management.mdx Co-authored-by: Néda <[email protected]> * Update pages/serverless-jobs/how-to/automate-resources-management.mdx Co-authored-by: Néda <[email protected]> --------- Co-authored-by: Néda <[email protected]>
1 parent 6bfa25d commit 2681b00

File tree

3 files changed

+88
-1
lines changed

3 files changed

+88
-1
lines changed

menu/navigation.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4681,6 +4681,10 @@
46814681
"label": "Build and push a container image",
46824682
"slug": "build-push-container-image"
46834683
},
4684+
{
4685+
"label": "Automate resources management with Jobs",
4686+
"slug": "automate-resources-management"
4687+
},
46844688
{
46854689
"label": "Manage the scheduling of a job",
46864690
"slug": "manage-job-schedule"

pages/scaleway-cli/quickstart.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,8 @@ Refer to the [Scaleway CLI repository](https://github.com/scaleway/scaleway-cli)
198198

199199
<Message type="note">
200200
Refer the the [Scaleway CLI repository](https://github.com/scaleway/scaleway-cli?tab=readme-ov-file#reference-documentation) for more information on the different commands.
201-
</Message>
201+
</Message>
202+
203+
## Going Further
204+
205+
You can periodically execute CLI commands with Serverless Jobs to automate the management of your Scaleway resources. Refer to the [dedicated documentation](/serverless-jobs/how-to/automate-resources-management/) for more information.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
meta:
3+
title: How to automate the management of your resources using Serverless Jobs
4+
description: This step-by-step guide will help you automate the management of your resources using Serverless Jobs and the Scaleway CLI
5+
content:
6+
h1: How to automate the management of your resources using Serverless Jobs
7+
paragraph: This step-by-step guide will help you automate the management of your resources using Serverless Jobs and the Scaleway CLI
8+
tags: serverless jobs command line interface cli automate resources management
9+
categories:
10+
- developer-tools
11+
- jobs
12+
dates:
13+
validation: 2025-06-13
14+
posted: 2025-06-13
15+
---
16+
[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.
17+
18+
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.
19+
20+
<Macro id="requirements" />
21+
22+
- A Scaleway account logged into the [console](https://console.scaleway.com).
23+
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization.
24+
25+
## Creating the job definition
26+
27+
1. In the [Scaleway console](https://console.scaleway.com), click **Jobs** in the **Serverless** section of the side menu. The jobs page displays.
28+
29+
2. Click **Create job**. The job creation wizard displays.
30+
31+
3. For **Container Image**, select **External**, and in **Image URL**, set: `scaleway/cli:latest`.
32+
33+
4. Enter a name or use the automatically generated one.
34+
35+
5. Select the region in which your job will be created.
36+
37+
6. Keep the default **resources** values, as this job requires little compute capability.
38+
39+
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.
40+
41+
8. Define the following environment variables:
42+
- `SCW_ACCESS_KEY`: your API access key.
43+
- `SCW_SECRET_KEY`: your API secret key.
44+
- `SCW_DEFAULT_PROJECT_ID`: your Project ID.
45+
- `SCW_DEFAULT_ORGANIZATION_ID`: your Organization ID.
46+
- `SCW_DEFAULT_REGION`: desired region.
47+
48+
<Message type="note">
49+
We recommend using [Secret Manager](/secret-manager/quickstart/) to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`.
50+
</Message>
51+
52+
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).
53+
54+
9. In the **Execution** tab, define the desired Scaleway CLI command, as shown in the examples below:
55+
- **Power on and off Instances**
56+
```sh
57+
# Power on
58+
scw instance server start 11111111-1111-1111-1111-111111111111
59+
60+
# Power off
61+
scw instance server stop 11111111-1111-1111-1111-111111111111
62+
```
63+
- **Create a snapshot of an Instance volume**
64+
```sh
65+
scw instance snapshot create volume-id=11111111-1111-1111-1111-111111111111
66+
```
67+
- **Create a backup of an Instance**
68+
```sh
69+
scw instance server backup 11111111-1111-1111-1111-111111111111
70+
```
71+
10. Click **Create job**.
72+
73+
Your Serverless Job will run the command periodically according to the [cron schedule](/serverless-jobs/reference-content/cron-schedules/) you defined.
74+
75+
## Running the job
76+
77+
From the **Overview** tab of the Serverless job you just created, click **Actions**, then select **Run job** from the contextual menu.
78+
79+
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**.

0 commit comments

Comments
 (0)