From eba2dc6ce4155d0ae6d1d08d56e8f7bce52b010a Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Fri, 13 Jun 2025 14:36:47 +0200 Subject: [PATCH 1/8] docs(srv): how to automate scw resource mgmt w/ jobs MTA-6074 --- .../how-to/automate-resources-management.mdx | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 pages/serverless-jobs/how-to/automate-resources-management.mdx diff --git a/pages/serverless-jobs/how-to/automate-resources-management.mdx b/pages/serverless-jobs/how-to/automate-resources-management.mdx new file mode 100644 index 0000000000..e499e5a28a --- /dev/null +++ b/pages/serverless-jobs/how-to/automate-resources-management.mdx @@ -0,0 +1,69 @@ +--- +meta: + title: How to automate the management of your resources using Serverless Jobs + description: This step-by-step guide will help you automate the management of your resources using Serverless Jobs and the Scaleway CLI +content: + h1: How to automate the management of your resources using Serverless Jobs + paragraph: This step-by-step guide will help you automate the management of your resources using Serverless Jobs and the Scaleway CLI +tags: serverless jobs command line interface cli automate resources management +categories: + - developer-tools + - jobs +dates: + validation: 2025-06-13 + posted: 2025-06-13 +--- +[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 auo automate the management of your Scaleway resources. + +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. + + + +- A Scaleway account logged into the [console](https://console.scaleway.com). +- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization. + +## Creating the job definition + +1. In the [Scaleway console](https://console.scaleway.com), click **Jobs** in the **Serverless** section of the side menu. The jobs page displays. + +2. Click **Create job**. The job creation wizard displays. + +3. For **Container Image**, select **External**, and in **Image URL**, set: `scaleway/cli:latest`. + +4. Enter a name or use the automatically generated one. + +5. Select the region in which your job will be created. + +6. Keep the default **resources** values, as this job requires little compute capability. + +7. Optionally, set a **cron schedule** (in the `* * * * *` format), 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. + +8. Define the following environment variables: + - `SCW_ACCESS_KEY`: your API access key. + - `SCW_SECRET_KEY`: your API secret key. + - `SCW_DEFAULT_PROJECT_ID`: your Project ID. + - `SCW_DEFAULT_ORGANIZATION_ID`: your Organization ID. + - `SCW_DEFAULT_REGION`: desired region. + + + We recommend using [Secret Manager](/secret-manager/quickstart/) to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`. + + + 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). + +9. In the **Execution** tab, define the desired Scaleway CLI command, as shown in the examples below: + + + + + + + + +10. Click **Create job**. + +## Running the job + +From the **Overview** tab of the Serverless job you just created, click **Actions**, then select **Run job** from the contextual menu. + +The execution appears in the **Job runs** section. You can access the logs of your job by clicking next to the job run ID, and selecting **See on Cockpit**. From 9e0beb9e9d479dcac65b4bfe2a28c484174360d7 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Fri, 13 Jun 2025 14:46:46 +0200 Subject: [PATCH 2/8] docs(srv): update --- menu/navigation.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/menu/navigation.json b/menu/navigation.json index 09f1fc3d44..73bd1f07f7 100644 --- a/menu/navigation.json +++ b/menu/navigation.json @@ -4677,6 +4677,10 @@ "label": "Build and push a container image", "slug": "build-push-container-image" }, + { + "label": "Automate resources management with Jobs", + "slug": "automate-resources-management" + }, { "label": "Manage the scheduling of a job", "slug": "manage-job-schedule" From c4c539cbfc8876b519ad0ae8a39398bbbd73985e Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Fri, 13 Jun 2025 17:21:59 +0200 Subject: [PATCH 3/8] docs(srv): update --- .../how-to/automate-resources-management.mdx | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/pages/serverless-jobs/how-to/automate-resources-management.mdx b/pages/serverless-jobs/how-to/automate-resources-management.mdx index e499e5a28a..5829ce93b4 100644 --- a/pages/serverless-jobs/how-to/automate-resources-management.mdx +++ b/pages/serverless-jobs/how-to/automate-resources-management.mdx @@ -52,14 +52,22 @@ Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not n 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). 9. In the **Execution** tab, define the desired Scaleway CLI command, as shown in the examples below: - - - - - - - - + - **Power on and off Instances** + ```sh + # Power on + scw instance server start 11111111-1111-1111-1111-111111111111 + + # Power off + scw instance server stop 11111111-1111-1111-1111-111111111111 + ``` + - **Create a snapshot of an Instance volume** + ```sh + scw instance snapshot create volume-id=11111111-1111-1111-1111-111111111111 + ``` + - **Create a backup of an Instance** + ```sh + scw instance server backup 11111111-1111-1111-1111-111111111111 + ``` 10. Click **Create job**. ## Running the job From 969fcbd01dde8f185fd97172b30557349b413700 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Mon, 16 Jun 2025 10:15:46 +0200 Subject: [PATCH 4/8] docs(srv): update --- pages/scaleway-cli/quickstart.mdx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pages/scaleway-cli/quickstart.mdx b/pages/scaleway-cli/quickstart.mdx index ebba7a3e38..80b27d31e8 100644 --- a/pages/scaleway-cli/quickstart.mdx +++ b/pages/scaleway-cli/quickstart.mdx @@ -198,4 +198,8 @@ Refer to the [Scaleway CLI repository](https://github.com/scaleway/scaleway-cli) 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. - \ No newline at end of file + + +## Going Further + +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. \ No newline at end of file From f571d9bb4fc53ce0c13811c7f74e2473c298ab42 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Mon, 16 Jun 2025 10:21:05 +0200 Subject: [PATCH 5/8] docs(srv): update --- .../serverless-jobs/how-to/automate-resources-management.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pages/serverless-jobs/how-to/automate-resources-management.mdx b/pages/serverless-jobs/how-to/automate-resources-management.mdx index 5829ce93b4..70582a59f2 100644 --- a/pages/serverless-jobs/how-to/automate-resources-management.mdx +++ b/pages/serverless-jobs/how-to/automate-resources-management.mdx @@ -36,7 +36,7 @@ Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not n 6. Keep the default **resources** values, as this job requires little compute capability. -7. Optionally, set a **cron schedule** (in the `* * * * *` format), 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. +7. Set a **cron schedule** (in the `* * * * *` format), 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. 8. Define the following environment variables: - `SCW_ACCESS_KEY`: your API access key. @@ -70,6 +70,8 @@ Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not n ``` 10. Click **Create job**. +your Serverless Job will run the command periodically according to the [cron schedule](/serverless-jobs/reference-content/cron-schedules/) you defined. + ## Running the job From the **Overview** tab of the Serverless job you just created, click **Actions**, then select **Run job** from the contextual menu. From 94e1f478523eda0cb50f79d19627b648c5df4477 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Mon, 16 Jun 2025 10:34:15 +0200 Subject: [PATCH 6/8] docs(srv): update --- pages/serverless-jobs/how-to/automate-resources-management.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/serverless-jobs/how-to/automate-resources-management.mdx b/pages/serverless-jobs/how-to/automate-resources-management.mdx index 70582a59f2..b48041743e 100644 --- a/pages/serverless-jobs/how-to/automate-resources-management.mdx +++ b/pages/serverless-jobs/how-to/automate-resources-management.mdx @@ -36,7 +36,7 @@ Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not n 6. Keep the default **resources** values, as this job requires little compute capability. -7. Set a **cron schedule** (in the `* * * * *` format), 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. +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. 8. Define the following environment variables: - `SCW_ACCESS_KEY`: your API access key. From fb497ef3906d412f5844a306b2669f21e571a6ad Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Tue, 17 Jun 2025 11:03:30 +0200 Subject: [PATCH 7/8] Update pages/serverless-jobs/how-to/automate-resources-management.mdx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Néda <87707325+nerda-codes@users.noreply.github.com> --- pages/serverless-jobs/how-to/automate-resources-management.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/serverless-jobs/how-to/automate-resources-management.mdx b/pages/serverless-jobs/how-to/automate-resources-management.mdx index b48041743e..87afc1e2c9 100644 --- a/pages/serverless-jobs/how-to/automate-resources-management.mdx +++ b/pages/serverless-jobs/how-to/automate-resources-management.mdx @@ -13,7 +13,7 @@ dates: validation: 2025-06-13 posted: 2025-06-13 --- -[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 auo automate the management of your Scaleway resources. +[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. 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. From 5b4ec78332cf469d7008c47ffacd5f9258b6298c Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Tue, 17 Jun 2025 11:03:39 +0200 Subject: [PATCH 8/8] Update pages/serverless-jobs/how-to/automate-resources-management.mdx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Néda <87707325+nerda-codes@users.noreply.github.com> --- pages/serverless-jobs/how-to/automate-resources-management.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/serverless-jobs/how-to/automate-resources-management.mdx b/pages/serverless-jobs/how-to/automate-resources-management.mdx index 87afc1e2c9..b05d4ef50d 100644 --- a/pages/serverless-jobs/how-to/automate-resources-management.mdx +++ b/pages/serverless-jobs/how-to/automate-resources-management.mdx @@ -70,7 +70,7 @@ Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not n ``` 10. Click **Create job**. -your Serverless Job will run the command periodically according to the [cron schedule](/serverless-jobs/reference-content/cron-schedules/) you defined. +Your Serverless Job will run the command periodically according to the [cron schedule](/serverless-jobs/reference-content/cron-schedules/) you defined. ## Running the job