Getting started with Workflows
Note
Workflows is at the Preview stage.
Using this tutorial, you will create and run a workflow. During the execution of the workflow, the Yandex Cloud Functions functions will be called.
Getting started
To get started in Yandex Cloud:
- Log in to the management console
. If not signed up yet, navigate to the management console and follow the on-screen instructions. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and its status isACTIVEorTRIAL_ACTIVE. If you do not have a billing account yet, create one. - If you do not have a folder yet, create one.
Create a service account
- In the management console
, select the folder for your service account. - Go to Identity and Access Management.
- Click Create service account.
- Name the service account:
sa-for-function. - Click
Add role and selectfunctions.functionInvoker. - Click Create.
Create a function to filter data
- In the management console
, select the folder to create your function in. - Go to Cloud Functions.
- Create a function:
- In the top-right corner, click Create function.
- Enter the function name:
filter-function. - Click Create.
- Create a function version:
- In the Editor window that opens, select
Node.js 22. - Disable Add files with code examples.
- Click Continue.
- Create a file named
index.jsand add the following code into it:module.exports.handler = async function (data, context) { return { id: data.id, name: data.name, email: data.email, }; }; - Under Parameters, specify the following in the field:
- Entry point:
index.handler - Service account:
sa-for-function
- Entry point:
- Click Save changes.
- In the Editor window that opens, select
Create a function to return email addresses
- In the management console
, select the folder to create your function in. - Go to Cloud Functions.
- Create a function:
- In the top-right corner, click Create function.
- Enter the function name:
return-function. - Click Create.
- Create a function version:
- In the Editor window that opens, select
Node.js 22. - Disable Add files with code examples.
- Click Continue.
- Create a file named
index.jsand add the following code into it:module.exports.handler = async function (data, context) { return { result: "OK", emails: data.loaded_users.map(p => p.email) }; }; - Under Parameters, specify the following in the field:
- Entry point:
index.handler - Service account:
sa-for-function
- Entry point:
- Click Save changes.
- In the Editor window that opens, select
Create a workflow
-
In the management console
, select the folder where you want to create a workflow. -
Go to Serverless Integrations.
-
In the left-hand panel, select
Workflows. -
In the top-right corner, click Create workflow.
-
In the YaML specification field, add the specification below. In the
functionIdfield:- In line 39, step
process_user_transform_info, specify thefilter-functionID. - In line 44, step
upload_users, specify thereturn-functionID.
yawl: "0.1" start: get_users defaultRetryPolicy: maxDelay: 10s retryCount: 2 errorList: - STEP_QUOTA_EXCEEDED steps: get_users: httpCall: url: 'https://jsonplaceholder.typicode.com/\(.resource_type)' method: GET headers: {} query: {} output: '\({loaded_users: .})' next: process_users process_users: foreach: input: \(.loaded_users) output: '\({loaded_users: .})' next: upload_users do: start: process_user_get_info steps: process_user_get_info: httpCall: url: https://jsonplaceholder.typicode.com/users/\(.id) method: GET headers: {} query: {} next: process_user_transform_info output: '\({user: .})' retryPolicy: retryCount: 2 errorList: - HTTP_CALL_500 process_user_transform_info: functionCall: functionId: <function_ID> upload_users: functionCall: functionId: "<function_ID>" input: '\({loaded_users, resource_type})' - In line 39, step
-
Expand the Additional parameters section:
-
In the Name field, enter the workflow name.
-
In the Service account field, select the
sa-for-functionservice account. -
Click Create.
Run the workflow
-
Select a workflow.
-
In the top-right corner, click
Execute. -
Enter input data in JSON format and click Execute.
Input data in JSON format:
{ "resource_type": "users" } -
When the workflow status changes from
RunningtoCompleted, the following JSON formatted result will appear in the Output data section:{ "result": "OK", "emails": [ "Sincere@april.biz", "Shanna@melissa.tv", "Nathan@yesenia.net", "Julianne.OConner@kory.org", "Lucio_Hettinger@annie.ca", "Karley_Dach@jasper.info", "Telly.Hoeger@billy.biz", "Sherwood@rosamond.me", "Chaim_McDermott@dana.io", "Rey.Padberg@karina.biz" ] }