If you want to use an event source such as Object Storage Service (OSS) to trigger function execution, you can grant the event source the permissions to trigger the execution. You can grant the permissions to the role of each trigger, and assign this role to different triggers. This topic describes the scenarios and procedure on how to grant permissions to an event source to access Function Compute. In this topic, the OSS event source is used as an example to access Function Compute.
- Log on to the Function Compute console.
- In the left-side navigation pane, click Services and Functions.
- In the top navigation bar, select the region where your Kubernetes cluster is deployed.
- On the Services page, find the service that you want to manage and click Functions in the Actions column.
- On the Functions page, click the name of the function that you want to manage.
- On the function details page, click the Triggers tab, select the version or alias from the Version or Alias drop-down list, and then click Create Trigger.
- In the Create Trigger panel, enter the relevant information. Click OK. Note If you want to grant permissions to other types of triggers, perform the steps as described in this section. You only need to select a trigger type based on your business requirements. The event source of an HTTP trigger is created when you create an HTTP function.
Parameter Description Example Trigger Type The type of the trigger. Select OSS. OSS Name The name of the trigger. Enter a custom trigger name. oss-trigger Version or Alias The version or alias of the service. The default value is LATEST. If you want to create a trigger for another version or alias, select a version or alias from the Version or Alias drop-down list on the function details page. For more information about versions and aliases of a service, see Manage versions and Manage aliases. LATEST Bucket Name The name of the OSS bucket. Select an OSS bucket from the drop-down list. bucket-zh**** Object Prefix The prefix of the object that you want to match. We recommend that you configure prefixes and suffixes to avoid additional costs generated by function execution loops. If you specify the same event type for different triggers of a bucket, the prefixes or suffixes cannot be repeated. For more information, see Trigger rules. source Object Suffix The suffix of the object name you want to match. We recommend that you configure prefixes and suffixes to avoid additional costs generated by function execution loops. If you specify the same event type for different triggers of a bucket, the prefixes or suffixes cannot be repeated. For more information, see Trigger rules. zip
The trigger event. Select one or more trigger events from the drop-down list. For more information about OSS events, see Definition of OSS events.
In this example, oss:ObjectCreated:PutObject is selected.
oss:ObjectCreated:PutObject Role Name The name of the role. Select AliyunOSSEventNotificationRole.Note After you set the preceding parameters, click OK. If you create a trigger of this type for the first time, click Authorize Now in the dialog box that appears. AliyunOSSEventNotificationRole
- Click OK.