本文說明如何在 Dataform 中執行下列操作:
事前準備
- 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. - 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.
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
Verify that billing is enabled for your Google Cloud project.
Roles required to enable APIs
To enable APIs, you need the serviceusage.services.enable permission. 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
Verify that billing is enabled for your Google Cloud project.
Roles required to enable APIs
To enable APIs, you need the serviceusage.services.enable permission. 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.
授予 Dataform 必要存取權
本節說明如何授予 Dataform 服務代理程式和自訂服務帳戶執行 BigQuery 工作流程所需的 Identity and Access Management (IAM) 角色。
關於自訂服務帳戶和 Dataform 服務代理人
您可以透過下列方式設定自訂服務帳戶,代表您執行工作流程:
- 在「存放區」層級,執行特定存放區中的所有工作流程。
- 每個工作流程設定都會個別計費。
建立 Dataform 存放區或工作流程設定時,您可以選取任何具備「扮演」權限的服務帳戶。您必須為與 Dataform 資源相關聯的所有服務帳戶,設定必要的「act-as」權限。
建立第一個 Dataform 存放區時,Dataform 會自動產生服務代理程式。Dataform 會使用服務代理程式代表您與 BigQuery 互動。
Dataform 服務代理 ID 的格式如下:
service-PROJECT_NUMBER@gcp-sa-dataform.iam.gserviceaccount.com
將 PROJECT_NUMBER 替換為專案的數字 ID。Google Cloud 您可以在 Google Cloud 控制台資訊主頁中找到專案 ID。Google Cloud 詳情請參閱「尋找專案名稱、編號和 ID」。
Dataform 服務代理、自訂服務帳戶和 Google 帳戶的必要角色
用於在 Dataform 中驗證的 Dataform 服務代理程式、自訂服務帳戶和 Google 帳戶的使用者憑證 (搶先版),必須具備下列 BigQuery IAM 角色,才能在 BigQuery 中執行工作流程:
- BigQuery 資料編輯者
(
roles/bigquery.dataEditor) 專案,Dataform 需要這些專案的讀取和寫入權限。這些通常包括代管 Dataform 存放區的專案。 - Dataform 需要唯讀存取權的專案,請授予「BigQuery 資料檢視者」(
roles/bigquery.dataViewer) 角色。 - 專案的 BigQuery 工作使用者
(
roles/bigquery.jobUser),該專案會代管您的 Dataform 存放區。 - BigQuery 資料擁有者
(
roles/bigquery.dataOwner) (如要查詢 BigQuery 資料集)。 - 資料欄層級存取控管的 BigQuery 角色,如果您想使用 BigQuery 政策標記。
此外,請在工作流程設定的有效服務帳戶中,將下列角色授予 Dataform 服務代理。您必須具備這些角色,才能使用嚴格的 act-as 模式。
如要自動發布存放區和自動執行工作流程,請在有效服務帳戶中,授予 Dataform 服務代理人 iam.serviceAccounts.actAs 權限。
安全性考量
將 Dataform 服務代理、自訂服務帳戶或使用者 Google 帳戶 (搶先版) 所需的角色授予這些對象時,請注意下列安全性考量事項:
無論 VPC Service Controls 為何,只要自訂服務帳戶獲得必要角色,就能存取服務帳戶所屬專案中的 BigQuery 或 Secret Manager。當 Dataform 使用自訂服務帳戶執行工作流程時,系統會將 Dataform 要求視為源自於包含存放區的專案 VPC Service Controls 範圍內。因此,如果這些資源位於相同的服務範圍內,VPC Service Controls 不會封鎖 Dataform 與其他服務 (例如 BigQuery 或 Secret Manager) 之間的通訊。
如要進一步瞭解如何管理這些安全邊界,請參閱「設定 VPC Service Controls」。
只要使用者擁有
dataform.repositories.createIAM 權限,就能使用 Dataform 服務代理程式和授予該服務代理程式或服務帳戶的所有權限執行程式碼。詳情請參閱「Dataform 權限的安全考量」。
為維持安全的權限模型,請定期稽核 Dataform 服務代理程式角色繫結。如需詳細的監控操作說明,請參閱「使用 Security Command Center 監控服務代理程式權限」。
如要限制使用者、服務代理程式或服務帳戶在 BigQuery 中讀取或寫入的資料,您可以將精細的 BigQuery IAM 權限授予所選的 BigQuery 資料集或資料表。詳情請參閱「控管資料集存取權」和「控管資料表和檢視區塊的存取權」。
為防止使用者在其他使用者的 Google 帳戶中執行動作,系統會強制執行下列限制:
- 如要使用附加至工作流程的其他 Google 帳戶使用者憑證修改工作流程設定,您必須將自己 Google 帳戶的使用者憑證附加至工作流程設定,或變更工作流程設定,以便透過自訂服務帳戶進行驗證。
- 如果工作流程設定參照的發行設定已附加其他 Google 帳戶使用者的憑證,您就無法修改發行設定的彙整結果。
您無法將工作流程設定為透過 Google 帳戶使用者憑證進行驗證,也無法參照排程發布設定。這項限制會造成下列影響:
- 如果工作流程設定參照的發布設定已設為使用 Google 帳戶使用者憑證進行驗證,您就無法更新發布設定,改為使用時間表。
- 您無法建立工作流程設定,透過 Google 帳戶使用者憑證進行驗證,並指向具有時間表的發布設定。
- 您無法建立或更新工作流程設定,以使用 Google 帳戶使用者憑證,並指向排定發布時間的發布設定。
授予必要的 BigQuery 角色
如要將必要的 BigQuery IAM 角色授予 Dataform 服務代理程式、要在 Dataform 中使用的自訂服務帳戶,或要用於在 Dataform 中驗證的使用者 Google 帳戶 (搶先版),請按照下列步驟操作:
前往 Google Cloud 控制台的「Dataform」頁面。