All Products
Search
Document Center

4. Create OSS trigger

Last Updated: Oct 16, 2018

Create trigger

  1. Log on to the Function Compute console.

  2. Click Triggers on the code execution page.

    Triggers

  3. Set the trigger type as Object Storage Service (OSS), and select the new bucket.

  4. Select oss:objectCreated:* as the trigger event, and source/ as the prefix.

    This configuration indicates that the function is triggered immediately when a new object is created with a source/ prefix in the bucket.

  5. In Invocation Role Management, select Select an existing role. The system provides a role named AliyunOSSEventNotificationRole for the OSS trigger, and you can select this role directly as the trigger role.

    The trigger needs to set a trigger role to authorize the execution of the function. OSS needs to play this role to trigger the function. For more information on permissions, see User permissions.

Test trigger

After the OSS trigger is set, you can test the entire project. You can upload a new image to the corresponding source/ directory in the Bucket in OSS console, and you find a new resized image of the same name in the processed/ directory.