This topic describes how to create a workflow to invoke Function Compute. The workflow contains one Task-type step.
Prerequisites
A function is created. For more information about how to create a function, see the "Create a function" section of the Manage functions topic.
Procedure
In this example, the Create Flow with Code method is used to create a workflow.
Log on to the Serverless Workflow console.
In the top navigation bar, select a region.
ImportantYou must select the region in which the function is created.
On the Flows page, click Create flow.
On the Create Flow page, click Create Flow with Code and configure parameters.
NoteYou can also use the Hello World and Sample Projects methods to create a workflow. However, if you use one of these methods to create a workflow, you cannot modify Definition.
Name: Specify a name for the workflow. The name must be 1 to 128 characters in length and can contain letters, digits, underscores (_), and hyphens (-). It cannot start with an underscore (_).
Description (Optional): Enter a description for the workflow.
Definition: Configure a workflow definition in a graphic interface.
You must change the content in the YAML file of Definition to the following code:
version: v1 type: flow steps: - type: task name: hello resourceArn: acs:fc:{region}:{accountID}:services/{serviceName}/functions/{functionName}
The following table describes the parameters that are included in the YAML file.
Parameter
Description
version
The version of the workflow. Only
v1
is supported.type
The type of the workflow. Default value:
flow
.steps
The steps of the workflow.
type
The type of the steps.
task
: The task type. For the step types when the type parameter is set to other value, see Overview.name
The name of the step. You can specify a step name.
resourceArn
The cloud service to be integrated.
You can view the Alibaba Cloud Resource Name (ARN) in the created function and copy the ARN for use. For more information, see Obtain the ARN of a function.
You can also replace {region}, {accountID}, {serviceName}, and {functionName} with the region, account ID, service name, and name of the created function. Example:
acs:fc:cn-shanghai:18807708****3420:services/demo/functions/test
.
Click Next.
Configure a workflow role.
NoteIf other cloud services such as Function Compute need to be invoked in you workflow, you can configure a workflow role in the Config Flow Role section to grant Serverless Workflow the permission to invoke the cloud services such as Function Compute. For more information, see Create execution roles.
If RAM roles exist, you can click Select an existing RAM role.
If you are using Serverless Workflow for the first time, you can create a RAM role by performing the following operations:
In the Config Flow Role section, click Create a RAM role. Enter a value in the Role Name field.
Select AliyunFCInvocationAccess from the System Policies drop-down list and click Create Role.
On the Role Templates page, click Confirm Authorization Policy.
On the Create Flow page, click Create Flow.
After the workflow is created, the following page is displayed.
Notes
In addition to using the Serverless Workflow console, you can also call the CreateFlow API operation to create a workflow. For more information, see CreateFlow.