Skip to content

Commit 1ef8f31

Browse files
SamyOubouazizRoRoJ
andauthored
docs(CLI): add how to & macro for Jobs automation MTA-6323 (#5319)
* docs(CLI): add how to & macro for Jobs automation MTA-6323 * docs(CLI): update * Apply suggestions from code review Co-authored-by: Rowena Jones <[email protected]> --------- Co-authored-by: Rowena Jones <[email protected]>
1 parent adce882 commit 1ef8f31

File tree

5 files changed

+108
-67
lines changed

5 files changed

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

menu/navigation.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2797,6 +2797,16 @@
27972797
],
27982798
"label": "Additional Content",
27992799
"slug": "reference-content"
2800+
},
2801+
{
2802+
"items": [
2803+
{
2804+
"label": "Automate resources management with the CLI and Jobs",
2805+
"slug": "automate-resources-management"
2806+
}
2807+
],
2808+
"label": "How To",
2809+
"slug": "how-to"
28002810
}
28012811
],
28022812
"label": "Scaleway CLI",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: How to automate the management of your resources using the Scaleway CLI and Serverless Jobs
3+
description: This step-by-step guide will help you automate the management of your resources using Serverless Jobs and the Scaleway CLI
4+
tags: serverless jobs command line interface cli automate resources management
5+
categories:
6+
- developer-tools
7+
- jobs
8+
dates:
9+
validation: 2025-06-23
10+
posted: 2025-06-13
11+
---
12+
13+
import AutomateResourcesManagement from '@macros/serverless-jobs/automate-resources-management.mdx'
14+
15+
<AutomateResourcesManagement />

pages/scaleway-cli/quickstart.mdx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ Refer to the [Scaleway CLI repository](https://github.com/scaleway/scaleway-cli)
198198
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.
199199
</Message>
200200

201-
## Going Further
201+
## Automate CLI actions with Scaleway Serverless Jobs
202202

203-
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.
203+
You can automate your CLI actions by scheduling them with Scaleway Serverless Jobs. This allows you to run your Scaleway CLI commands at specific times or intervals without needing to manually execute them.
204+
205+
For step-by-step guides, check out the following tutorials:
206+
- [Power your Instances on and off using Serverless Jobs](https://www.scaleway.com/en/docs/tutorials/power-on-off-instances-jobs/)
207+
- [Create snapshots of a Managed MongoDB® database](https://www.scaleway.com/en/docs/tutorials/backup-mongodb-jobs/)
208+
- [Create recurring scheduled backups and snapshots of a database](https://www.scaleway.com/en/docs/tutorials/snapshot-managed-databases/)
209+
- [Create snapshots of an Instance](https://www.scaleway.com/en/docs/tutorials/snapshot-instances-jobs/)
210+
211+
Refer to the [dedicated documentation](/scaleway-cli/how-to/automate-resources-management/) for more information.

pages/serverless-jobs/how-to/automate-resources-management.mdx

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,70 +9,7 @@ dates:
99
validation: 2025-06-23
1010
posted: 2025-06-13
1111
---
12-
import Requirements from '@macros/iam/requirements.mdx'
1312

13+
import AutomateResourcesManagement from '@macros/serverless-jobs/automate-resources-management.mdx'
1414

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

Comments
 (0)