使用 Google Cloud 控制台建立工作流程
本快速入門導覽課程說明如何使用 Google Cloud 控制台,建立、部署及執行您的第一項工作流程。範例工作流程會向公開 API 傳送要求,然後傳回 API 的回應。
如要直接在 Google Cloud 控制台中,按照這項工作的逐步指南操作,請按一下「Guide me」(逐步引導):
事前準備
貴機構定義的安全性限制,可能會導致您無法完成下列步驟。如需疑難排解資訊,請參閱「在受限的 Google Cloud 環境中開發應用程式」。
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
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.
-
如要使用現有專案進行本指南中的操作,請確認您具有所需的權限。如果您建立新專案,則已具備必要權限。
-
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 Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. 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.
-
如要使用現有專案進行本指南中的操作,請確認您具有所需的權限。如果您建立新專案,則已具備必要權限。
-
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 Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles. - 設定驗證方法:
-
Ensure that you have the Create Service Accounts IAM role
(
roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles. -
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart. - Click Create and continue.
-
Grant the Logging > Logs Writer role to the service account.
To grant the role, find the Select a role list, then select Logging > Logs Writer.
- Click Continue.
-
Click Done to finish creating the service account.
-
Ensure that you have the Create Service Accounts IAM role
(
如要進一步瞭解服務帳戶角色和權限,請參閱授予工作流程存取 Google Cloud 資源的權限。
必要的角色
如要取得完成本快速入門導覽課程所需的權限,請要求管理員在專案中授予您下列 IAM 角色:
-
服務帳戶使用者 (
roles/iam.serviceAccountUser) -
Workflows 管理員 (
roles/workflows.admin)
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
建立及部署工作流程
前往 Google Cloud 控制台的「Workflows」頁面:
在「Workflows」頁面中,按一下 「Create」(建立)。
輸入新工作流程的名稱,例如
myFirstWorkflow。選擇「us-central1」做為區域。
在「服務帳戶」部分,選取您先前建立的服務帳戶。
選取「下一步」。
-
YAML
JSON
除非您自行輸入搜尋字詞,否則工作流程會使用您的Google Cloud 位置建構搜尋字詞,並將搜尋字詞傳送至 Wikipedia API。系統會傳回相關的維基百科文章清單。
選取 [Deploy] (部署)。
執行工作流程
成功部署工作流程後,即可首次執行。部署工作流程之後,系統會將您帶往「Workflow details」(工作流程詳細資料) 頁面。
在「工作流程詳細資料」頁面中,按一下「執行」。
在「Execute workflow」(執行工作流程) 頁面中,按一下「Execute」(執行)。
「Output」(輸出) 窗格會顯示工作流程結果。
您已部署並執行第一項工作流程!
清除所用資源
為了避免系統向您的 Google Cloud 帳戶收取本頁面所用資源的費用,請按照下列步驟操作。
前往 Google Cloud 控制台的「Workflows」頁面:
在工作流程清單中,按一下工作流程,前往「Workflow details」(工作流程詳細資料) 頁面。
按一下 「Delete」(刪除)。
輸入工作流程名稱,然後按一下「確認」。