Skip to content

Commit 06feff9

Browse files
SamyOubouazizRoRoJ
andauthored
docs(srv): Jobs x Instances power cycle tuto MTA-6097 (#5091)
* docs(srv): add quotas for Jobs MTA-6094 * Apply suggestions from code review Co-authored-by: Rowena Jones <36301604+RoRoJ@users.noreply.github.com> --------- Co-authored-by: Rowena Jones <36301604+RoRoJ@users.noreply.github.com>
1 parent eaecad1 commit 06feff9

File tree

2 files changed

+124
-1
lines changed

2 files changed

+124
-1
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
meta:
3+
title: Power your Instance on and off with Serverless Jobs and the Scaleway CLI
4+
description: This step-by-step tutorial will help you automate the startup and shutdown of your Instance using Serverless Jobs and the Scaleway CLI
5+
content:
6+
h1: Power your Instance on and off with Serverless Jobs and the Scaleway CLI
7+
paragraph: This step-by-step tutorial will help you automate the startup and shutdown of your Instance using Serverless Jobs and the Scaleway CLI
8+
tags: serverless jobs instance cli turn on off power start stop reboot
9+
categories:
10+
- instances
11+
- jobs
12+
dates:
13+
validation: 2025-06-09
14+
posted: 2025-06-09
15+
---
16+
[Scaleway Serverless Jobs](/serverless-jobs/quickstart/) allows you to create and automate recurring tasks. This tutorial will guide you through the process of powering a [Scaleway Instance](/instances/quickstart/) on and off, on a recurring schedule using a Serverless Job.
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+
- Created an [Instance](/instances/how-to/create-an-instance/).
25+
26+
## Creating the job definitions
27+
28+
### Serverless Job to power on the Instance
29+
30+
1. In the [Scaleway console](https://console.scaleway.com), click **Jobs** in the **Serverless** section of the side menu. The jobs page displays.
31+
32+
2. Click **Create job**. The job creation wizard displays.
33+
34+
3. For **Container Image**, select **External**, and in **Image URL**, set: `scaleway/cli:latest`.
35+
36+
4. Enter a name or use the automatically generated one.
37+
38+
5. Select the region in which your job will be created.
39+
40+
6. Keep the default **resources** values, as this job requires little compute capability.
41+
42+
7. Set **cron schedule** to `0 9 * * 1-5` and select the relevant time zone to run the job every morning at 9:00 a.m (09:00) from Monday through Friday. Refer to the [cron schedules documentation](/serverless-jobs/reference-content/cron-schedules/) for more information.
43+
44+
8. Define the following environment variables:
45+
- `SCW_ACCESS_KEY`: your API access key.
46+
- `SCW_SECRET_KEY`: your API secret key.
47+
- `SCW_DEFAULT_PROJECT_ID`: your Project ID.
48+
- `SCW_DEFAULT_ORGANIZATION_ID`: your Organization ID.
49+
- `SCW_DEFAULT_REGION`: the preferred region.
50+
51+
<Message type="note">
52+
We recommend using Secret Manager to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`.
53+
</Message>
54+
55+
For more details about variables used by `cli`, refer to the [CLI config documentation](https://cli.scaleway.com/instance/#power-on-server).
56+
57+
9. In the **Execution** tab, enter the command below, and replace the placeholder with your Instance ID:
58+
59+
```
60+
scw instance server start 11111111-1111-1111-1111-111111111111
61+
```
62+
63+
10. Click **Create job**.
64+
65+
### Serverless Job to power off the Instance
66+
67+
1. In the [Scaleway console](https://console.scaleway.com), click **Jobs** in the **Serverless** section of the side menu. The jobs page displays.
68+
69+
2. Click **Create job**. The job creation wizard displays.
70+
71+
3. For **Container Image**, select **External**, and in **Image URL**, set: `scaleway/cli:latest`.
72+
73+
4. Enter a name or use the automatically generated one.
74+
75+
5. Select the region in which your job will be created.
76+
77+
6. Keep the default **resources** values, as this job requires little compute capability.
78+
79+
7. Set **cron schedule** to `0 18 * * 1-5` and select the relevant time zone to run the job every evening at 6:00 p.m (18:00) from Monday through Friday. Refer to the [cron schedules documentation](/serverless-jobs/reference-content/cron-schedules/) for more information.
80+
81+
8. Define the following environment variables:
82+
- `SCW_ACCESS_KEY`: your API access key.
83+
- `SCW_SECRET_KEY`: your API secret key.
84+
- `SCW_DEFAULT_PROJECT_ID`: your Project ID.
85+
- `SCW_DEFAULT_ORGANIZATION_ID`: your Organization ID.
86+
- `SCW_DEFAULT_REGION`: the preferred region.
87+
88+
<Message type="note">
89+
We recommend using Secret Manager to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`.
90+
</Message>
91+
92+
For more details about variables used by `cli`, refer to the [CLI config documentation](https://cli.scaleway.com/instance/#power-on-server).
93+
94+
9. In the **Execution** tab, enter the command below, and replace the placeholder with your Instance ID:
95+
96+
```
97+
scw instance server stop 11111111-1111-1111-1111-111111111111
98+
```
99+
100+
10. Click **Create job**.
101+
102+
## Testing the jobs
103+
104+
According to the current state of your Instance, run either the **Power on** or **Power off** job first.
105+
106+
From the **Overview** tab of each Serverless job you just created, click **Actions**, then select **Run job** from the contextual menu.
107+
108+
The execution appears in the **Job runs** section. You can access the logs of your jobs by clicking <Icon name="more" /> next to the job run ID, and selecting **See on Cockpit**.
109+
110+
## Possible improvements
111+
112+
This tutorial is a lightweight example of how to manage the power cycle of an Instance. You can go further by:
113+
- Using it to manage all your Instances' power cycles
114+
- Using Jobs to create [snapshots of your Instances](/tutorials/snapshot-instances-jobs/)
115+
- Setting up an alerting system in case of unexpected behavior
116+
- Exploring [scaleway/serverless-examples repository](https://github.com/scaleway/serverless-examples) for advanced automation examples
117+
118+
## Additional resources
119+
120+
- [Serverless Jobs Documentation](/serverless-jobs/how-to/create-job/)
121+
- [Other methods to deploy Jobs](/serverless-jobs/reference-content/deploy-job/)
122+
- [API keys documentation](/iam/how-to/create-api-keys/)
123+
- [CRON schedule reference](/serverless-jobs/reference-content/cron-schedules/)

tutorials/snapshot-instances-jobs/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ categories:
1010
- instances
1111
- jobs
1212
dates:
13-
validation: 2025-12-03
13+
validation: 2025-03-12
1414
posted: 2024-06-19
1515
---
1616
[Scaleway Serverless Jobs](/serverless-jobs/quickstart/) allows you to create and automate recurring tasks. This tutorial will guide you through the process of creating snapshots of a [Scaleway Instance](/instances/quickstart/) on a recurring schedule using a Serverless Job.

0 commit comments

Comments
 (0)