From ce57f5fadd9e86907c336c3d88fa71fe0a33ab68 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Mon, 9 Jun 2025 15:43:28 +0200 Subject: [PATCH 1/2] docs(srv): add quotas for Jobs MTA-6094 --- .../power-on-off-instances-jobs/index.mdx | 123 ++++++++++++++++++ tutorials/snapshot-instances-jobs/index.mdx | 2 +- 2 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 tutorials/power-on-off-instances-jobs/index.mdx diff --git a/tutorials/power-on-off-instances-jobs/index.mdx b/tutorials/power-on-off-instances-jobs/index.mdx new file mode 100644 index 0000000000..957603a604 --- /dev/null +++ b/tutorials/power-on-off-instances-jobs/index.mdx @@ -0,0 +1,123 @@ +--- +meta: + title: Power on and off your Instance with Serverless Jobs and the Scaleway CLI + description: This step-by-step tutorial will help you automate the startup and shutdown of your Instance using Serverless Jobs and the Scaleway CLI +content: + h1: Power on and off your Instance with Serverless Jobs and the Scaleway CLI + paragraph: This step-by-step tutorial will help you automate the startup and shutdown of your Instance using Serverless Jobs and the Scaleway CLI +tags: serverless jobs instance cli turn on off power start stop reboot +categories: + - instances + - jobs +dates: + validation: 2025-06-09 + posted: 2025-06-09 +--- +[Scaleway Serverless Jobs](/serverless-jobs/quickstart/) allows you to create and automate recurring tasks. This tutorial will guide you through the process of powering on and off a [Scaleway Instance](/instances/quickstart/) on a recurring schedule using a Serverless Job. + +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. +- Created an [Instance](/instances/how-to/create-an-instance/). + +## Creating the job definitions + +### Serverless Job to power on the Instance + +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 **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. + +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`: concerned region. + + + We recommend using Secret Manager 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://cli.scaleway.com/instance/#power-on-server). + +9. In the **Execution** tab, enter the command below, and replace the placeholder with your Instance ID: + + ``` + scw instance server start 11111111-1111-1111-1111-111111111111 + ``` + +10. Click **Create job**. + +### Serverless Job to power off the Instance + +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 **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. + +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`: concerned region. + + + We recommend using Secret Manager 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://cli.scaleway.com/instance/#power-on-server). + +9. In the **Execution** tab, enter the command below, and replace the placeholder with your Instance ID: + + ``` + scw instance server stop 11111111-1111-1111-1111-111111111111 + ``` + +10. Click **Create job**. + +## Testing the jobs + +According to the current state of your Instance, Run either the **Power on** or **Power off** job first. + +From the **Overview** tab of each 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 jobs by clicking next to the job run ID, and selecting **See on Cockpit**. + +## Possible improvements + +This tutorial is a lightweight example of how to manage the power cycle of an Instance. You can go further by: +- Using it to manage all your Instances' power cycles +- Using Jobs to create [snapshots of your Instances](/tutorials/snapshot-instances-jobs/) +- Setting up an alerting system in case of unexpected behavior +- Explore [scaleway/serverless-examples repository](https://github.com/scaleway/serverless-examples) for advanced automation examples + +## Additional resources + +- [Serverless Jobs Documentation](/serverless-jobs/how-to/create-job/) +- [Other methods to deploy Jobs](/serverless-jobs/reference-content/deploy-job/) +- [API keys documentation](/iam/how-to/create-api-keys/) +- [CRON schedule reference](/serverless-jobs/reference-content/cron-schedules/) diff --git a/tutorials/snapshot-instances-jobs/index.mdx b/tutorials/snapshot-instances-jobs/index.mdx index d87a940891..4b81288189 100644 --- a/tutorials/snapshot-instances-jobs/index.mdx +++ b/tutorials/snapshot-instances-jobs/index.mdx @@ -10,7 +10,7 @@ categories: - instances - jobs dates: - validation: 2025-12-03 + validation: 2025-03-12 posted: 2024-06-19 --- [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. From 607a04e33578a99fe5105e8e832c79519fbed4a8 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Wed, 11 Jun 2025 09:56:08 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Rowena Jones <36301604+RoRoJ@users.noreply.github.com> --- tutorials/power-on-off-instances-jobs/index.mdx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tutorials/power-on-off-instances-jobs/index.mdx b/tutorials/power-on-off-instances-jobs/index.mdx index 957603a604..de03c917aa 100644 --- a/tutorials/power-on-off-instances-jobs/index.mdx +++ b/tutorials/power-on-off-instances-jobs/index.mdx @@ -1,9 +1,9 @@ --- meta: - title: Power on and off your Instance with Serverless Jobs and the Scaleway CLI + title: Power your Instance on and off with Serverless Jobs and the Scaleway CLI description: This step-by-step tutorial will help you automate the startup and shutdown of your Instance using Serverless Jobs and the Scaleway CLI content: - h1: Power on and off your Instance with Serverless Jobs and the Scaleway CLI + h1: Power your Instance on and off with Serverless Jobs and the Scaleway CLI paragraph: This step-by-step tutorial will help you automate the startup and shutdown of your Instance using Serverless Jobs and the Scaleway CLI tags: serverless jobs instance cli turn on off power start stop reboot categories: @@ -13,7 +13,7 @@ dates: validation: 2025-06-09 posted: 2025-06-09 --- -[Scaleway Serverless Jobs](/serverless-jobs/quickstart/) allows you to create and automate recurring tasks. This tutorial will guide you through the process of powering on and off a [Scaleway Instance](/instances/quickstart/) on a recurring schedule using a Serverless Job. +[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. 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. @@ -46,7 +46,7 @@ Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not n - `SCW_SECRET_KEY`: your API secret key. - `SCW_DEFAULT_PROJECT_ID`: your Project ID. - `SCW_DEFAULT_ORGANIZATION_ID`: your Organization ID. - - `SCW_DEFAULT_REGION`: concerned region. + - `SCW_DEFAULT_REGION`: the preferred region. We recommend using Secret Manager to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`. @@ -83,7 +83,7 @@ Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not n - `SCW_SECRET_KEY`: your API secret key. - `SCW_DEFAULT_PROJECT_ID`: your Project ID. - `SCW_DEFAULT_ORGANIZATION_ID`: your Organization ID. - - `SCW_DEFAULT_REGION`: concerned region. + - `SCW_DEFAULT_REGION`: the preferred region. We recommend using Secret Manager to store the `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`. @@ -101,7 +101,7 @@ Serverless Jobs are perfectly adapted for these autonomous tasks, as we do not n ## Testing the jobs -According to the current state of your Instance, Run either the **Power on** or **Power off** job first. +According to the current state of your Instance, run either the **Power on** or **Power off** job first. From the **Overview** tab of each Serverless job you just created, click **Actions**, then select **Run job** from the contextual menu. @@ -113,7 +113,7 @@ This tutorial is a lightweight example of how to manage the power cycle of an In - Using it to manage all your Instances' power cycles - Using Jobs to create [snapshots of your Instances](/tutorials/snapshot-instances-jobs/) - Setting up an alerting system in case of unexpected behavior -- Explore [scaleway/serverless-examples repository](https://github.com/scaleway/serverless-examples) for advanced automation examples +- Exploring [scaleway/serverless-examples repository](https://github.com/scaleway/serverless-examples) for advanced automation examples ## Additional resources