OBS-triggered Functions

V1.0 – July 2024

Version Author Description
V1.0 – 2024-07-04 Diogo Hatz d50037923 Initial Version
V1.0 – 2024-07-04 Wisley da Silva Paulo 00830850 Document Review

Objective

This document aims to present the procedures required to create a function in the Huawei Cloud FunctionGraph serverless service with activation by uploading new objects to OBS buckets.

Agency

To delegate permissions from the object storage (OBS) service to FunctionGraph, it is necessary to create an agency with permissions over OBS. Navigate to the IAM service in the Huawei Cloud console and click the “Agencies” page. Click “Create Agency” to create an agency.

Give the agency a name, select the agency type as “Cloud Service”, and select the FunctionGraph service. Click “Next” to proceed.

Delegate “OBS ReadOnlyAccess” permissions to the agency and click “Next” and then “OK” to finish.

FunctionGraph

Access the FunctionGraph service in the Huawei Cloud console and navigate to the Functions > Function List page. Click “Create Function”.

Select the “Create from scratch” option, give the function a name, select the runtime in which the function will be executed, and select the agency created in item 2.0 of this document.

Once you have created the function, click “Create Trigger” to create a trigger for the function to be activated.

Select the Trigger Type as “Object Storage Service (OBS)”, select the desired bucket and the Event as “ObjectCreated”, so that the function is activated every time a new object appears in the bucket in question.

It is also possible to configure a prefix and a suffix of the specific objects that will trigger the function, by configuring a Prefix or Suffix.

Having created the trigger, now simply import the code that will be executed by the function in Code Source, such as APIs.

You can also add third-party dependencies and libraries by navigating to the bottom of the function panel.

Example

In this example, a Python function was written to make a request to a web server running on an ECS every time a new object appears in the bucket defined in item 3.0 of this document.

Uploading an object to the defined bucket:

Result in the server listener:

References