Updated on 2023-11-22 GMT+08:00

OBS Events

Huawei Cloud functions can be triggered by different event sources, which can be defined and configured through events.

OBS Events

In this example, an OBS event is set. Each time an object is uploaded to my-service-resource, the event triggers the first function.
# serverless.yml

functions:
  first:
    handler: index.first
    events:
      - obs:
          bucket: bucket
          events:
            - s3:ObjectCreated:Put
            - s3:ObjectCreated:Post
// index.js

exports.first = async (event, context) => {
  const response = {
    statusCode: 200,
    body: JSON.stringify({
      message: 'Hello!',
    }),
  };

  return response;
};