使用 Google Cloud 控制台创建工作流
本快速入门介绍了如何使用 Google Cloud 控制台创建、部署和执行第一个工作流。示例工作流会向公共 API 发送请求,然后返回该 API 的响应。
如需在 Google Cloud 控制台中直接遵循有关此任务的分步指导,请点击操作演示:
准备工作
您的组织定义的安全限制条件可能会导致您无法完成以下步骤。如需了解相关问题排查信息,请参阅在受限的 Google Cloud 环境中开发应用。
- 登录您的 Google Cloud 账号。如果您是 Google Cloud新手,请 创建一个账号来评估我们的产品在实际场景中的表现。新客户还可获享 $300 赠金,用于运行、测试和部署工作负载。
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Workflows API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Workflows API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.- 设置身份验证:
-
<0
-
确保您拥有 Create Service Accounts IAM 角色 (
roles/iam.serviceAccountCreator) 和 Project IAM Admin 角色 (roles/resourcemanager.projectIamAdmin)。了解如何授予角色。 -
在 Google Cloud 控制台中,前往创建服务账号页面。
转到“创建服务账号” - 选择您的项目。
-
在服务账号名称字段中,输入一个名称。 Google Cloud 控制台会根据此名称填充服务账号 ID 字段。
在服务账号说明字段中,输入说明。例如,
Service account for quickstart。 - 点击创建并继续。
-
向服务账号授予 Logging > Logs Writer 角色。
如需授予该角色,请找到选择角色列表,然后选择 日志记录 > 日志写入者。
- 点击继续。
-
点击完成以完成服务账号的创建过程。
-
确保您拥有 Create Service Accounts IAM 角色 (
如需详细了解服务账号角色和权限,请参阅授予工作流访问 Google Cloud 资源的权限。
所需的角色
如需获得完成本快速入门所需的权限,请让您的管理员为您授予项目的以下 IAM 角色:
- Service Account User (
roles/iam.serviceAccountUser) - Workflows Admin (
roles/workflows.admin)
如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。
创建和部署工作流
在 Google Cloud 控制台中,前往 Workflows 页面:
在工作流页面上,点击 创建。
输入新工作流的名称,例如
myFirstWorkflow。选择 us-central1 作为区域。
对于服务账号,选择您之前创建的服务账号。
选择下一步。
-
YAML
JSON
除非您输入自己的搜索字词,否则此工作流会使用您的Google Cloud 位置构造搜索字词,并将其传递给 Wikipedia API。系统会返回相关 Wikipedia 文章的列表。
选择部署。
执行工作流
工作流成功部署后,您可以首次执行该工作流。部署工作流后,您将转到其工作流详情页面。
在工作流详情页面上,点击 执行。
在执行工作流页面上,点击执行。
输出窗格中会显示工作流的结果。
您已部署并执行了第一个工作流程!
清理
为避免因本页中使用的资源导致您的 Google Cloud 账号产生费用,请按照以下步骤操作。
在 Google Cloud 控制台中,前往 Workflows 页面:
从工作流列表中,点击工作流以转至其工作流详情页面。
点击 删除。
输入工作流的名称,然后点击确认。