本文說明 Dataform 存放區的概念,以及如何建立新的存放區。
關於 Dataform 存放區
每個 Dataform 存放區都包含一組 SQLX 和 JavaScript 檔案,這些檔案構成工作流程,以及 Dataform 設定檔和套件。您可以在開發工作區中與存放區內容互動。
Dataform 頁面會依存放區 ID 的字母順序顯示存放區。你可以排序及篩選這些項目。
如要查看存放區,請前往 Google Cloud 控制台的「Dataform」頁面。
每個 Dataform 存放區都必須連結至自訂服務帳戶。您可以在建立存放區時選取自訂服務帳戶。 您稍後可以編輯服務帳戶。
Dataform 會使用 Git 記錄變更及管理檔案版本。每個 Dataform 存放區都會對應一個 Git 存放區。 建立 Dataform 存放區後,您可以將其連結至遠端 GitHub、GitLab 或 Bitbucket 存放區。
在 Dataform 存放區中,Dataform 會儲存存放區程式碼。在已連結的存放區中,第三方存放區會儲存存放區程式碼。 Dataform 會與第三方存放區互動,讓您在 Dataform 開發工作區中編輯及執行存放區內容。
Dataform 存放區頁面包含下列元件:
- 「開發工作區」分頁
- 顯示在存放區中建立的開發工作區。
- 「工作流程執行記錄」分頁
- 顯示 Dataform 工作流程執行記錄。
- 「版本與排程」分頁
- 可檢查、建立、編輯及刪除版本設定和工作流程設定。
- 「設定」分頁
- 顯示存放區的名稱和位置。如果存放區已連結至第三方 Git 存放區,系統會顯示第三方存放區來源、預設分支版本名稱和密鑰權杖。顯示按鈕,可將存放區連結至第三方 Git 存放區,以及編輯 Git 連線。
- 「建立開發工作區」按鈕
- 可讓您建立開發工作區。
建立並初始化開發工作區後,您可以編輯工作流程設定檔,設定存放區的下列 Dataform 設定:
- 預設資料庫 (Google Cloud 專案 ID)。
- 預設結構定義 (BigQuery 資料集 ID)。
- 預設 BigQuery 位置。
- 斷言的預設結構定義 (BigQuery 資料集 ID)。
- 倉庫,必須設為
bigquery。 - 編譯期間可供專案程式碼使用的使用者定義變數。
如要進一步瞭解 Dataform 存放區設定,請參閱 Dataform 核心參考資料中的 IProjectConfig。
存放區設定
建立 Dataform 存放區時,您需要設定下列存放區設定:
- 存放區 ID
- 存放區的專屬 ID。ID 只能使用數字、英文字母、連字號和底線。
- 區域
用於儲存存放區及其內容的 Dataform 區域。
這個儲存區域可以與處理區域不同,Dataform 會在處理區域處理程式碼,並儲存執行作業的輸出內容。根據預設,處理區域會設為預設 BigQuery 資料集區域。建立存放區後,您可以在工作流程設定檔中編輯處理區域。詳情請參閱「設定 Dataform 工作流程設定」。
- 服務帳戶
與存放區相關聯的自訂服務帳戶。您可以選取與 Google Cloud 專案相關聯的服務帳戶,或手動輸入其他服務帳戶。
您必須使用自訂服務帳戶,才能在存放區中執行工作流程。 所有其他存放區作業都由預設的 Dataform 服務代理程式執行。
- 嚴格的「充當」模式
啟用額外的安全檢查,需要服務帳戶的
iam.serviceAccounts.actAs權限。所有存放區都會強制執行嚴格的「以...身分行動」模式。- 加密
存放區的加密方法。您可以使用預設加密、專屬的客戶管理 Cloud KMS 加密金鑰,或預設的 Dataform CMEK 金鑰。如要進一步瞭解如何在 Dataform 中使用客戶自行管理的加密金鑰 (CMEK),請參閱「使用客戶自行管理的加密金鑰」。
建立存放區後,您可以將其連結至 GitHub 或 GitLab。
事前準備
- 登入 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.
-
Verify that billing is enabled for your Google Cloud project.
Enable the BigQuery and Dataform APIs.
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.
-
Verify that billing is enabled for your Google Cloud project.
Enable the BigQuery and Dataform APIs.
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.- 如要為存放區使用 CMEK 加密,請