From cf335fede13442d117b71292ecbdcade62f4d544 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Thu, 7 Mar 2024 16:15:56 +0100 Subject: [PATCH 1/3] docs(SRV): rework transform images tutorial MTA-4240 --- .../index.mdx | 48 ++----------------- 1 file changed, 4 insertions(+), 44 deletions(-) diff --git a/tutorials/transform-bucket-images-triggers-functions-set-up/index.mdx b/tutorials/transform-bucket-images-triggers-functions-set-up/index.mdx index 76b0889206..218d0e9501 100644 --- a/tutorials/transform-bucket-images-triggers-functions-set-up/index.mdx +++ b/tutorials/transform-bucket-images-triggers-functions-set-up/index.mdx @@ -15,30 +15,18 @@ dates: posted: 2023-07-07 --- -## Introduction - -This tutorial is the first of a series of two. You will learn how to set up your environment, then [how to create and deploy functions](/tutorials/transform-bucket-images-triggers-functions-deploy/) to resize images stored in a bucket and push them to another bucket. - - - Serverless Functions are an asynchronous microservices architecture where event sources are decorrelated from event consumers. -They work best when they are triggered by events stored in queues, which means that they can be edited without having to modify every microservice in the process. +They work best when they are triggered by specific events, such as cron schedules, which means that they can be edited without having to modify every microservice in the process. -In this tutorial, you will create the following resources to use your functions: - -- A project dedicated to this tutorial -- Two buckets to store media -- A queue to manage events -- IAM credentials to secure your environment -- Cockpit to monitor your functions +In this tutorial, we will deploy a function that manipulates images stored in a source bucket and push them to another bucket using the [AWS SDK for Javascript](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3/). - You have an account and are logged into the [Scaleway console](https://console.scaleway.com). - - You have around ten JPG or PNG images. - - You have a code editor installed. + - You have [NodeJS](https://nodejs.org/en/download) and [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) installed. + - You have at least ten JPG or PNG images. ## Creating a New Project @@ -67,34 +55,6 @@ In this tutorial, you will create the following resources to use your functions: 5. Set the bucket visibility to **Private**. 6. Click **Create Bucket**. -## Creating a Messaging and Queuing namespace - -Message queues allow functions to communicate with each other. - -1. Click **Messaging** under **Serverless**. -2. Click **Create namespace**. -3. Choose **SQS/SNS** as type. -4. Choose a name or generate one. -5. Click **Create namespace**. - -## Generating credentials for the M&Q namespace - -1. Click on the namespace you just created. -2. Click **Generate credentials**. -3. Name your credentials `Function Push`. -4. Enable the **Write**, **Read** and **Manage** permissions. -5. Click **Generate credentials**. -6. Store the access key ID and the secret key securely, as you will not be able to access them later. - -## Creating a Queue - -1. Click the **Queues** tab of your namespace. -2. Click **Create queue**. -3. Select **Standard** as a queue type. -4. Name it `image-queue`. -5. Keep the default parameters. -6. Click **Create queue**. - ## Creating IAM credentials Identity and Access Management (IAM) credentials allow you to secure access to your buckets, functions, etc. From ab88ab583c843134f821cbef19f0237e59d82c10 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Mon, 8 Apr 2024 09:44:51 +0200 Subject: [PATCH 2/3] fix(SRV): update tutorials with correct procedure MTA-4240 --- .../index.mdx | 20 +++++++++++++++---- .../index.mdx | 8 ++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tutorials/transform-bucket-images-triggers-functions-deploy/index.mdx b/tutorials/transform-bucket-images-triggers-functions-deploy/index.mdx index 38ab18d53a..0030efef7e 100644 --- a/tutorials/transform-bucket-images-triggers-functions-deploy/index.mdx +++ b/tutorials/transform-bucket-images-triggers-functions-deploy/index.mdx @@ -131,12 +131,19 @@ You will now learn how to deploy Serverless Functions and connect them using tri ``` 5. Save the file and exit the editor. -6. Run the following command in the same terminal to download the required dependencies: + +6. Run the following command in the same terminal to initialize a new NPM project and create an empty `package.json` file: + + ```sh + npm init --yes + ``` + +7. Run the following command to download the required dependencies and packages: ```bash npm i @aws-sdk/client-s3 @aws-sdk/client-sqs @scaleway/serverless-functions ``` -7. Run the following command in the same terminal to zip the content of the folder: +8. Run the following command in the same terminal to zip the content of the folder: ```bash zip -r BucketScan.zip . @@ -277,14 +284,19 @@ You will now learn how to deploy Serverless Functions and connect them using tri ``` 4. Save the file and exit the code editor. -5. Run the following command in the same terminal to download the required dependencies and packages: +5. Run the following command in the same terminal to initialize a new NPM project and create an empty `package.json` file: + + ```sh + npm init --yes + ``` +6. Run the following command to download the required dependencies and packages: ```bash npm i @aws-sdk/client-s3 @aws-sdk/client-sqs @scaleway/serverless-functions npm install sharp --platform=linuxmusl --arch=x64 sharp --ignore-script=false ``` -6. Run the following command in the same terminal to zip the content of the folder: +7. Run the following command in the same terminal to zip the content of the folder: ```bash zip -r ImageTransform.zip . diff --git a/tutorials/transform-bucket-images-triggers-functions-set-up/index.mdx b/tutorials/transform-bucket-images-triggers-functions-set-up/index.mdx index f91b76e46a..aa1df80719 100644 --- a/tutorials/transform-bucket-images-triggers-functions-set-up/index.mdx +++ b/tutorials/transform-bucket-images-triggers-functions-set-up/index.mdx @@ -64,14 +64,14 @@ In this tutorial, you will create the following resources to use your functions: Message queues allow functions to communicate with each other. -1. Click **Messaging** under **Serverless**. +1. Click **Messaging** under **Serverless** on the left side menu of the console. 2. Click **Activate** next to **SQS**. 3. Click **Activate SQS** to confirm when prompted. ## Generating credentials for Messaging and Queuing SQS -1. In **Messaging and Queuing** > **SQS**, click the **Credentials** tab. -2. Click **Generate credentials**. +1. Click **Messaging** under **Serverless** on the left side menu of the console, then select **SQS**. +2. Click **+ Generate credentials**. 3. Name your credentials `Function Push`. 4. Enable the **Write**, **Read** and **Manage** permissions. 5. Click **Generate credentials**. @@ -79,7 +79,7 @@ Message queues allow functions to communicate with each other. ## Creating a Queue -1. Click the **Queues** tab of SQS. +1. Click **Messaging** under **Serverless** on the left side menu of the console, then select **SQS**. 2. Click **Create queue**. 3. Select **Standard** as a queue type. 4. Name it `image-queue`. From f168cbb8b968e8941aa15e3eb3c713e71740f338 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Mon, 8 Apr 2024 12:02:16 +0200 Subject: [PATCH 3/3] docs(srv): update --- .../index.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tutorials/transform-bucket-images-triggers-functions-set-up/index.mdx b/tutorials/transform-bucket-images-triggers-functions-set-up/index.mdx index aa1df80719..1c56764bcf 100644 --- a/tutorials/transform-bucket-images-triggers-functions-set-up/index.mdx +++ b/tutorials/transform-bucket-images-triggers-functions-set-up/index.mdx @@ -17,7 +17,7 @@ dates: Serverless Functions are an asynchronous microservices architecture where event sources are decorrelated from event consumers. -They work best when they are triggered by specific events, such as cron schedules, which means that they can be edited without having to modify every microservice in the process. +They work best when they are triggered by specific events, such as cron schedules, which means they can be edited without having to modify every microservice in the process. In this tutorial, you will create the following resources to use your functions: @@ -31,10 +31,10 @@ In this tutorial, you will create the following resources to use your functions: - A Scaleway account logged into the [console](https://console.scaleway.com) -- Around 10 JPG or PNG images -- A code editor installed +- Installed [Node.js](https://nodejs.org/en/download) and [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) +- At least 10 JPG or PNG images -## Creating a new Project +## Creating a Project 1. Click the **Projects** tab from the [Organization Dashboard](https://console.scaleway.com/organization). A list of your Projects displays. 2. Click **+ Create Project** on the right-hand side. A pop-up displays.