Use Wasabi Hot Storage with the Koyeb Serverless Platform

November 02, 2020

Édouard Bonlieu

Édouard Bonlieu
@edouardb_

Warning! This tutorial is deprecated.

The guide below is based on older versions of Koyeb and Wasabi and will no longer work without modification. This page remains available for reference purposes only. Please let us know on the Koyeb community platform if you would like to see an updated version of this guide.


What is Koyeb

Koyeb is certified for use with Wasabi. The Koyeb serverless cloud platform allows developers and businesses to run production-grade data-processing apps in minutes.

With Koyeb, you can build your event-driven processing workflows combining Docker containers, custom functions, and ready-to-use processing integration. Trigger your functions when a file is modified in your Wasabi bucket thanks to the Koyeb S3 API gateway.

Koyeb is ideal to process any kind of data, from media files (photos, videos, audio, PDFs) to logs, CSV, and much more.

Why Use Wasabi with Koyeb

Combining your Wasabi buckets with the Koyeb serverless engine is the perfect way to benefit from your data by analyzing, optimizing, or transforming them without any complex configurations or infrastructure management.

With Koyeb, you deploy event-driven functions and define which S3 events trigger your functions. For instance, you can easily deploy a function performing image label detection when a new image is uploaded to your bucket, generate video transcripts, resize images, and more.

Spend less time operating complex infrastructures, and spend more time easily building powerful features on top of your data.

How to Connect Your Wasabi Bucket to Koyeb

To connect your Wasabi bucket to Koyeb, you will need to do the two following steps:

  1. Generate Access Keys in Wasabi
  2. Connect Wasabi to Koyeb with your Wasabi Access Keys

Generate Access Keys in Wasabi

To get started, you need to generate a Wasabi Access key pair to connect your Wasabi bucket to Koyeb. Connecting your Wasabi bucket to Koyeb is a necessary step to access the Koyeb processing engine.

To generate a new Wasabi access key pair, login to your Wasabi account.

Once in your account, click on the key icon in the left-side menu. Then click Create New Access Key.

Wasabi Credentials

A modal appears.

  • Select Root User
  • Then click Create

Wasabi Modal

A new screen in the modal appears.

You can see your Access Key. To see your Secret Key, click Show if you would like to see your Secret Key.

Click Copy Keys to Clipboard to copy these secret values. You will need these values, Access Key and Secret Key, during the next step, which is to connect your Wasabi buckets to Koyeb.

Now that you have generated your Wasabi Secret Keys, make sure to save them in a safe place. You can only see these values once, and they are critical to the security of your data.

Connect Wasabi to Koyeb with your Wasabi Access Keys

Now that you have generated a Wasabi Access Key pair, you can connect your Wasabi bucket to Koyeb. By connecting your Wasabi bucket to Koyeb, Koyeb can receive the events that occur in your Wasabi bucket and trigger your functions when a new image is uploaded.

  1. From the Koyeb Control panel, click the Create button on the top right navigation bar and select Store.
  2. You will land on the Store creation page. In the list of cloud service providers, select Wasabi.

Select Wasabi Store

  1. Fill in the form that appears below with the information about the Wasabi bucket you want to connect:

Enter Wasabi Bucket Info

  • Fill the bucket input with your Wasabi bucket name
  • Enter the region your bucket is located
  • Under Access_key, click the Create new Secret button to securely add the access key you previously created in Wasabi.
    • Name: Enter a name for this key, such as wasabiaccesskey
    • Value: Enter the Wasabi access key you previously saved as the value
    • Click Submit
  • For Access-key, select the Secret name you just created as value for the access key. For example, wasabiaccesskey
  • Under Secret_key, click the Create new Secret button to securely add the private key you previously created in Wasabi.
    • Name: Enter a name for this key, such as wasabisecretkey
    • Value: Enter the Wasabi private key you previously saved as the value
  • For Secret_key, select the Secret name you just created as value for the secret key. For example, wasabisecretkey
  • Name the Koyeb Store, for example wasabi-koyeb-store
  • Click the Create Store button

You've now connected your Wasabi bucket to Koyeb! You can upload data here to trigger data-processing functions.

Connected Wasabi Store

Process your Wasabi data with Koyeb catalog apps

Now that your Wasabi bucket is connected to Koyeb, you can deploy your first processing function!

As mentioned previously, Koyeb allows you to deploy processing functions written in Node.js or Python, Docker containers, or ready-to-use functions from the Koyeb catalog using Koyeb Stacks. Koyeb Stacks are processing environments composed of an event bus to receive events and functions triggered by user-defined events.

Below, we will explain how to deploy functions to process your Wasabi data.

Using a Koyeb catalog app

In this example, we will deploy the image resize function. This function allows you to automatically resize images at upload.

To deploy this function, in the Koyeb control panel:

  1. Click the Create button on the top navigation bar.
  2. Select Stack.
  3. Choose Simple Koyeb Versioning.
  4. Give your Stack a name.
  5. Click Create Stack.

You Stack is now created. It's time to deploy the first revision. Revisions are used to keep a history of your changes and allow you to return to a previous version at any time.

In the dropdown, select Image Resize, the following snippet appears in the editor. To configure the function to resize uploaded images, replace the STORE value with your Koyeb Store name (remove the <>). You can also edit other parameters as needed.

functions: - name: image-resize use: image-resize@1.0.0 with: STORE: #The store to watch to trigger the function and save the resized image. This parameter is required. <YOUR_VALUE> IMAGE_RESIZE_WIDTH: #The desired image width. Set to auto if not defined. This parameter is optional. 100 IMAGE_RESIZE_PATH: #The path to store the new generated image. This parameter is optional. resized-images/ IMAGE_RESIZE_FORMAT: #The format of the new generated image. This parameter is optional. jpeg

Once ready, click the Deploy revision button.

Your Stack is provisioning your functions and in a few seconds, all images uploaded to your Koyeb Store via the interface or using the Koyeb S3-gateway will be resized automatically.

To confirm everything is working fine, on the Koyeb control panel:

  1. Click Stores.
  2. Select the Store you previously created and connected to Wasabi
  3. Click the Upload button and upload some images.
  4. A folder resized-images appears containing all the images uploaded resized.

All the data is stored on the Wasabi cloud!

Go deeper

To learn more about how to deploy Docker containers or custom code, how to use the Koyeb S3 gateway or learn more about Koyeb check out the Koyeb documentation.

Questions or suggestions to improve this guide? Join us on the community platform to chat!

Welcome to Koyeb

Koyeb is a developer-friendly serverless platform to deploy any apps globally.

Start for free
Start for free, pay as you grow

Deploy 2 services for free and enjoy our predictable pricing as you grow

Deploy your first app in no time

Get up and running in 5 minutes