All Products
Search
Document Center

Function Compute (2.0):Overview of OSS event triggers

Last Updated:Jan 19, 2024

After you integrate Object Storage Service (OSS) with Function Compute, OSS events can trigger the execution of functions to process data in OSS buckets. This topic describes the limits, event types, and triggering rules of native OSS triggers and EventBridge-based OSS triggers in Function Compute.

Background information

OSS is seamlessly integrated with Function Compute by using OSS triggers. You can write functions and invoke the functions by using OSS events. When OSS captures an event of a specific type, the event triggers the execution of the corresponding function. For example, you can write a function to process PutObject events. When you call the PutObject operation of OSS to upload an image to OSS, the function is invoked to process the image.

After OSS is integrated with Function Compute, you can invoke various functions to process images and audio data, and write the results to multiple storage services. In the entire process, you need only to focus on writing the function logic. Function Compute can process large amounts of data in real time and in parallel.

Limits

  • Only native OSS triggers support the query of all associated triggers of a bucket.

    You can reuse existing OSS triggers or delete OSS triggers that are no longer used based on your business requirements. This prevents the number of triggers associated with your bucket from exceeding 10. On the Trigger Management (URL) tab of the function details page, find the trigger that you want to manage and click the bucket name in the Configurations column. In the OSS Bucket-related Triggers panel, you can view the OSS triggers that are associated with the bucket.

    created-oss-trigger

    Note

    Deleted triggers cannot be restored. Proceed with caution when you delete a trigger.

  • You can configure multiple object prefixes and suffixes only for EventBridge-based OSS triggers. For more information, see Configure an EventBridge-based OSS trigger.

  • Regular expression matching is not supported for object prefixes and suffixes that you configure for native OSS triggers and EventBridge-based OSS triggers. For more information, see Configure a native OSS trigger and Configure an EventBridge-based OSS trigger.

  • If you want to associate more than 10 OSS triggers with a bucket, you can associate only EventBridge-based OSS triggers. For more information, see Configure an EventBridge-based OSS trigger.

    We recommend that you do not associate more than 10 triggers with a bucket. If you want to associate more triggers, we recommend that you create a new bucket and create new triggers based on the new bucket.

OSS events

When OSS captures an event, OSS encodes the event information as a JSON string and passes the string to the corresponding event processing function. For more information about the format of OSS event notifications, see the "Event notifications" section of the Use event notifications to monitor object changes in real time topic.

The following table describes the OSS events supported by Function Compute. Each event type corresponds to an ObjectCreated, ObjectRemoved, or ObjectModified operation. After an operation is called as expected, the function is triggered and executed once.

Event Type

Event name

Description

ObjectCreated

oss:ObjectCreated:PutObject

The PutObject operation is called to upload an object. For more information, see PutObject.

oss:ObjectCreated:PutSymlink

The PutSymlink operation is called to create a symbolic link for a destination object in OSS. You can use this symbolic link to access the destination object. For more information, see PutSymlink.

oss:ObjectCreated:PostObject

The PostObject operation is called to upload a file to a specified bucket by using an HTML form. For more information, see PostObject.

oss:ObjectCreated:CopyObject

The CopyObject operation is called to copy an existing object in OSS. For more information, see CopyObject.

oss:ObjectCreated:InitiateMultipartUpload

Before you use multipart upload to upload data, the InitiateMultipartUpload operation must be called to notify OSS to initiate a multipart upload event. For more information, see InitiateMultipartUpload.

oss:ObjectCreated:UploadPart

After the multipart upload event is initiated, you can upload data in parts based on specified object names and upload IDs. For more information, see UploadPart.

oss:ObjectCreated:UploadPartCopy

The UploadPartCopy operation is called to copy data from an existing object to upload a part. For more information, see UploadPartCopy.

oss:ObjectCreated:CompleteMultipartUpload

The CompleteMultipartUpload operation is called to complete the multipart upload of an object. For more information, see CompleteMultipartUpload.

oss:ObjectCreated:AppendObject

The AppendObject operation is called to upload an object by appending the object to an existing object. For more information, see AppendObject.

oss:ObjectCreated:*

A function is triggered when one of the preceding ObjectCreated operations is called.

ObjectRemoved

oss:ObjectRemoved:DeleteObject

The DeleteObject operation is called to delete an object. For more information, see DeleteObject.

oss:ObjectRemoved:DeleteObjects

The DeleteMultipleObjects operation is called to delete multiple objects at a time. For more information, see DeleteMultipleObjects.

oss:ObjectRemoved:AbortMultipartUpload

The AbortMultipartUpload operation is called to cancel a multipart upload task based on the upload ID that you provide. For more information, see AbortMultipartUpload.

ObjectModified

oss:ObjectModified:UpdateObjectMeta

The UpdateObjectMeta operation is called to modify the attributes of an object.

Note

This type of event is supported in the following regions: China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Shenzhen), and China (Chengdu).

Triggering rules

Do not perform loop triggering

Warning

When you use OSS event triggers, do not perform loop triggering. For example, when you upload objects to an OSS bucket, the upload operation triggers a function. The function generates one or more objects that are written to the OSS bucket, and the write operation triggers the function again. This results in a loop.

To prevent extra costs caused by loop triggering, we recommend that you configure the Object Prefix parameter or the Object Suffix parameter when you create an OSS trigger. For example, you can set the prefix of the objects that are used to invoke a function to src and the prefix of the objects that are generated after the function is executed to dst. This way, the generated objects do not invoke the function again. If you do not specify the Object Prefix parameter or the Object Suffix parameter, objects with all prefixes and suffixes are matched. For more information, see Configure an OSS trigger.

Ensure the semantic uniqueness

The configuration semantics of a trigger must be unique across the bucket for which the trigger is created. The configurations include the Trigger Event parameter, the Object Prefix parameter, and the Object Suffix parameter. For example, you create a trigger whose trigger event is oss:ObjectCreated:PutObject for a bucket. The Object Prefix parameter and the Object Suffix parameter of the trigger are set to source and zip. The following table describes whether new triggers for the bucket are valid.

Trigger Event

Object Prefix

Object Suffix

Valid

Description

oss:ObjectCreated:*

source1

zip1

No

The new trigger is configured with the same type of event as the existing trigger.

Note

oss:ObjectCreated:* includes all ObjectCreated events. If you have created a trigger of the ObjectCreated event type in a bucket, you cannot create a trigger of the oss:ObjectCreated:* event type. Similarly, if you have created a trigger of the oss:ObjectCreated:* event type in a bucket, you cannot create a trigger of the ObjectCreated event.

oss:ObjectCreated:PutObject

source

zip

No

The new trigger is configured with the same values for the Object Prefix and Object Suffix parameters as the existing trigger.

source

None

No

The new trigger is configured with the same value for the Object Prefix parameter as the existing trigger. If you do not specify the Object Suffix parameter, objects with the zip suffix are included.

None

zip

No

The new trigger is configured with the same value for the Object Suffix parameter as the existing trigger. If you do not specify the Object Prefix parameter, objects with the source prefix are included.

source1

zip1

Yes

The new trigger is configured with different values for the Object Prefix and Object Suffix parameters from the existing trigger.

source

zip1

Yes

The new trigger is configured with a different value for the Object Suffix parameter from the existing trigger.

source1

zip

Yes

The new trigger is configured with a different value for the Object Prefix parameter from the existing trigger.

oss:ObjectCreated:PostObject

source

zip

Yes

The new trigger is configured with a different value for the Trigger Event parameter from the existing trigger.

Important

Semantic uniqueness must be ensured for native OSS triggers. Therefore, you cannot configure the same OSS trigger for different functions.

If you want to configure the same OSS trigger for different functions for the same event type, you can configure EventBridge-based OSS triggers. For more information, see Configure an EventBridge-based OSS trigger.

FAQ

References