From f4cfcf8ac2c10cff414d9dc6d03b784119df9136 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Tue, 22 Jul 2025 15:56:41 +0200 Subject: [PATCH 1/3] docs(CLI): add how to & macro for Jobs automation MTA-6323 --- .../automate-resources-management.mdx | 71 +++++++++++++++++++ menu/navigation.json | 10 +++ .../how-to/automate-resources-management.mdx | 15 ++++ pages/scaleway-cli/quickstart.mdx | 12 +++- .../how-to/automate-resources-management.mdx | 67 +---------------- 5 files changed, 108 insertions(+), 67 deletions(-) create mode 100644 macros/serverless-jobs/automate-resources-management.mdx create mode 100644 pages/scaleway-cli/how-to/automate-resources-management.mdx diff --git a/macros/serverless-jobs/automate-resources-management.mdx b/macros/serverless-jobs/automate-resources-management.mdx new file mode 100644 index 0000000000..caa3311d82 --- /dev/null +++ b/macros/serverless-jobs/automate-resources-management.mdx @@ -0,0 +1,71 @@ +--- +macro: automate-resources-management +--- + +import Requirements from '@macros/iam/requirements.mdx' + + +[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. + + + +- 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. 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. + - `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: + - **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**. + +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. + +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**. \ No newline at end of file diff --git a/menu/navigation.json b/menu/navigation.json index 07b1a0724a..8a5b51b3f5 100644 --- a/menu/navigation.json +++ b/menu/navigation.json @@ -2797,6 +2797,16 @@ ], "label": "Additional Content", "slug": "reference-content" + }, + { + "items": [ + { + "label": "Automate resources management with the CLI and Jobs", + "slug": "automate-resources-management" + } + ], + "label": "How To", + "slug": "how-to" } ], "label": "Scaleway CLI", diff --git a/pages/scaleway-cli/how-to/automate-resources-management.mdx b/pages/scaleway-cli/how-to/automate-resources-management.mdx new file mode 100644 index 0000000000..eee9f59657 --- /dev/null +++ b/pages/scaleway-cli/how-to/automate-resources-management.mdx @@ -0,0 +1,15 @@ +--- +title: How to automate the management of your resources using the Scaleway CLI and Serverless Jobs +description: 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-23 + posted: 2025-06-13 +--- + +import AutomateResourcesManagement from '@macros/serverless-jobs/automate-resources-management.mdx' + + \ No newline at end of file diff --git a/pages/scaleway-cli/quickstart.mdx b/pages/scaleway-cli/quickstart.mdx index c84c497293..de437bc61e 100644 --- a/pages/scaleway-cli/quickstart.mdx +++ b/pages/scaleway-cli/quickstart.mdx @@ -198,6 +198,14 @@ 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. -## Going Further +## Automate CLI actions with Scaleway Serverless Jobs -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 +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. + +For step-by-step guides, check out the following tutorials: +- [Power on and off your instances using Serverless Jobs](https://www.scaleway.com/en/docs/tutorials/power-on-off-instances-jobs/) +- [Create snapshots of a Managed MongoDB® database](https://www.scaleway.com/en/docs/tutorials/backup-mongodb-jobs/) +- [Create recurring scheduled backups and snapshots of a database](https://www.scaleway.com/en/docs/tutorials/snapshot-managed-databases/) +- [Create snapshots of an Instance](https://www.scaleway.com/en/docs/tutorials/snapshot-instances-jobs/) + +Refer to the [dedicated documentation](/serverless-jobs/how-to/automate-resources-management/) for more information. \ No newline at end of file diff --git a/pages/serverless-jobs/how-to/automate-resources-management.mdx b/pages/serverless-jobs/how-to/automate-resources-management.mdx index 83eb4d79fc..5f618c48d8 100644 --- a/pages/serverless-jobs/how-to/automate-resources-management.mdx +++ b/pages/serverless-jobs/how-to/automate-resources-management.mdx @@ -9,70 +9,7 @@ dates: validation: 2025-06-23 posted: 2025-06-13 --- -import Requirements from '@macros/iam/requirements.mdx' +import AutomateResourcesManagement from '@macros/serverless-jobs/automate-resources-management.mdx' -[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. - - - -- 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. 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. - - `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: - - **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**. - -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. - -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**. \ No newline at end of file + \ No newline at end of file From 3afbbf187d849d34ac52a3060135cc9ac7ff97ee Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Tue, 22 Jul 2025 15:59:12 +0200 Subject: [PATCH 2/3] docs(CLI): update --- pages/scaleway-cli/quickstart.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/scaleway-cli/quickstart.mdx b/pages/scaleway-cli/quickstart.mdx index de437bc61e..f3fd72dd58 100644 --- a/pages/scaleway-cli/quickstart.mdx +++ b/pages/scaleway-cli/quickstart.mdx @@ -208,4 +208,4 @@ For step-by-step guides, check out the following tutorials: - [Create recurring scheduled backups and snapshots of a database](https://www.scaleway.com/en/docs/tutorials/snapshot-managed-databases/) - [Create snapshots of an Instance](https://www.scaleway.com/en/docs/tutorials/snapshot-instances-jobs/) -Refer to the [dedicated documentation](/serverless-jobs/how-to/automate-resources-management/) for more information. \ No newline at end of file +Refer to the [dedicated documentation](/scaleway-cli/how-to/automate-resources-management/) for more information. \ No newline at end of file From 098e42b248c4114f3922a1f0f2ae3db6cfd7db40 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Wed, 23 Jul 2025 10:15:16 +0200 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Rowena Jones <36301604+RoRoJ@users.noreply.github.com> --- macros/serverless-jobs/automate-resources-management.mdx | 4 ++-- pages/scaleway-cli/quickstart.mdx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/macros/serverless-jobs/automate-resources-management.mdx b/macros/serverless-jobs/automate-resources-management.mdx index caa3311d82..c3fd56d6bd 100644 --- a/macros/serverless-jobs/automate-resources-management.mdx +++ b/macros/serverless-jobs/automate-resources-management.mdx @@ -44,7 +44,7 @@ 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** + - **Power Instances on and off** ```sh # Power on /scw instance server start 11111111-1111-1111-1111-111111111111 @@ -66,6 +66,6 @@ Your Serverless Job will run the command periodically according to the [cron sch ## 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 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**. \ No newline at end of file diff --git a/pages/scaleway-cli/quickstart.mdx b/pages/scaleway-cli/quickstart.mdx index f3fd72dd58..a47425d9af 100644 --- a/pages/scaleway-cli/quickstart.mdx +++ b/pages/scaleway-cli/quickstart.mdx @@ -203,7 +203,7 @@ Refer the the [Scaleway CLI repository](https://github.com/scaleway/scaleway-cli 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. For step-by-step guides, check out the following tutorials: -- [Power on and off your instances using Serverless Jobs](https://www.scaleway.com/en/docs/tutorials/power-on-off-instances-jobs/) +- [Power your Instances on and off using Serverless Jobs](https://www.scaleway.com/en/docs/tutorials/power-on-off-instances-jobs/) - [Create snapshots of a Managed MongoDB® database](https://www.scaleway.com/en/docs/tutorials/backup-mongodb-jobs/) - [Create recurring scheduled backups and snapshots of a database](https://www.scaleway.com/en/docs/tutorials/snapshot-managed-databases/) - [Create snapshots of an Instance](https://www.scaleway.com/en/docs/tutorials/snapshot-instances-jobs/)