This topic shows you how to use Serverless Devs in the Apsara Devops Flow console to deploy a function to Function Compute.

Prerequisites

Before you begin, make sure that you have completed the following operations:
  • Activate Function Compute.
  • Activate Flow.
  • Upload your business code to a code repository.
    Note
    • For more information about the types of code repositories that are supported by Flow, see Configure a source code repository.
    • In addition to your business code, you must also add the template.yml file for Funcraft and the s.yml file for Serverless Devs to the code repository. You can use the following configuration in the s.yml file:
      ProjectName:
        Component: fun
        Provider: alibaba
        Properties:
          Region: cn-qingdao #The region where you want to deploy a function.
          Config: s

Procedure

  1. Log on to the Flow console.
  2. In the upper-right corner of the My Pipelines page, click Create Pipeline.
  3. In the Select a pipeline template dialog box, select Empty Template in the Others section and click Create.
  4. In the Add Pipeline Source panel, select a code repository type, specify the code repository that you want to use and the default branch, and then click Add.
  5. In the Phase 1 section of the Process Configuration tab, click Empty Task. In the Edit panel, set the parameters as required.
  6. Click Save and Run in the upper-right corner. In the Confirm message, click OK to run the pipeline.
    After you click OK, the Recently Run tab appears. If the pipeline enters the Successful state, the function is deployed to Function Compute.

FAQ

Problem description: I have used a third-party cloud service or configured a trigger for a function. What can I do if I fail to use Flow to deploy the function to Function Compute?

Cause: The AliyunRDCDefaultRole RAM role that is assumed by Flow has limited permissions. Therefore, Flow may fail to deploy a function to Function Compute in the following scenarios:

Scenario Required permission and its feature
No specific RAM role is assumed by the function and a third-party cloud service is involved in the function configuration.
  • AliyunFCFullAccess: deploys the function.
  • AliyunRAMFullAccess: Based on the third-party cloud service involved, the Funcraft component of Serverless Devs automatically creates the fc-default-role-${function_name} RAM role and attaches the required permission policy to the RAM role.
  • ram:PassRole: assigns the specified RAM role to the third-party cloud service.
  • ram:GetRole: checks whether the fc-default-role-${function_name} RAM role exists and creates the RAM role and attaches the required permission policy to the RAM role if it does not exist.
A trigger is configured for the function. Function Compute supports the following types of triggers: Object Storage Service (OSS) event trigger, Message Service (MNS) topic trigger, Log Service trigger, Tablestore trigger, CDN event trigger, API Gateway trigger, and Cloud Monitor trigger. The read permissions or full access permissions on the Alibaba Cloud service involved: ensures that resources of the Alibaba Cloud service can be accessed when trigger resources are being created.
You can troubleshoot the issue by using one of the following methods:
  • Log on to the RAM console and attach the required permission policy to the AliyunRDCDefaultRole RAM role.
    Notice This method is applicable if you use an Alibaba Cloud account or a RAM user that is authorized to modify the permissions of a RAM role.
  • Configure Serverless Devs by using an Alibaba Cloud account or a RAM user that has sufficient permissions. For more information about the procedure, see Key configuration.
Note We recommend that you use the first method to configure permissions instead of configuring Serverless Devs by using an Alibaba Cloud account or a RAM user in the Flow console.