管理執行階段範本的存取權
本頁面說明如何在 Colab Enterprise 授予及撤銷執行階段範本的存取權。
事前準備
- 登入 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 Agent Platform, Dataform, and Compute Engine APIs, if any are not already enabled.
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 Agent Platform, Dataform, and Compute Engine APIs, if any are not already enabled.
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.
必要的角色
如要取得管理執行階段範本存取權所需的權限,請要求管理員授予您專案的 Colab Enterprise 管理員 (roles/aiplatform.colabEnterpriseAdmin) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
授予執行階段範本存取權
如要授予主體執行階段範本的存取權,可以使用 Google Cloud 控制台、Google Cloud CLI 或 Terraform。
控制台
-
前往 Google Cloud 控制台的 Colab Enterprise「Runtime templates」(執行階段範本) 頁面。
-
在「Region」(區域) 選單中,選取執行階段範本所在的區域。
-
在「Runtime template」(執行階段範本) 選單中,選取執行階段範本。如果沒有列出任何執行階段範本,請建立執行階段範本。
-
按一下 「Permissions」(權限)。
-
在「Permissions」(權限) 視窗中,按一下 「Add principal」(新增主體)。
-
在「Grant access」(授予存取權) 對話方塊的「New principals」(新增主體) 欄位中,輸入一個或多個主體 (以半形逗號分隔)。
-
在「Select a role」(請選擇角色) 選單中,完成對話方塊來指派角色。
-
選用:按一下「 Add another role」(新增其他角色),然後重複上一個步驟。
-
按一下「儲存」。
gcloud
使用下列任何指令資料前,請先替換以下項目:
RUNTIME_TEMPLATE_ID:執行階段範本的 ID。PRINCIPAL:要新增繫結的主體。ROLE:要指派給主體的角色名稱。PROJECT_ID:您的專案 ID。REGION:執行階段範本所在的區域。
執行下列指令:
Linux、macOS 或 Cloud Shell
gcloud colab runtime-templates add-iam-policy-binding RUNTIME_TEMPLATE_ID \ --member=PRINCIPAL \ --role=ROLE \ --project=PROJECT_ID \ --region=REGION
Windows (PowerShell)
gcloud colab runtime-templates add-iam-policy-binding RUNTIME_TEMPLATE_ID ` --member=PRINCIPAL ` --role=ROLE ` --project=PROJECT_ID ` --region=REGION
Windows (cmd.exe)
gcloud colab runtime-templates add-iam-policy-binding RUNTIME_TEMPLATE_ID ^ --member=PRINCIPAL ^ --role=ROLE ^ --project=PROJECT_ID ^ --region=REGION
如要進一步瞭解如何透過指令列管理執行階段範本的 IAM 政策,請參閱 gcloud CLI 說明文件。
Terraform
如要瞭解如何套用或移除 Terraform 設定,請參閱「基本 Terraform 指令」。詳情請參閱 Terraform 供應商參考文件。
下列範例使用 google_colab_runtime_template_iam_policy Terraform 資源,授予 Colab Enterprise 執行階段範本的存取權。
data "google_iam_policy" "admin" { binding { role = "roles/viewer" members = [ "user:jane@example.com", ] } } resource "google_colab_runtime_template_iam_policy" "policy" { project = google_colab_runtime_template.runtime-template.project location = google_colab_runtime_template.runtime-template.location runtime_template = google_colab_runtime_template.runtime-template.name policy_data = data.google_iam_policy.admin.policy_data }
Colab Enterprise 主體包括使用者、群組或網域
您可以將存取權授予使用者、群組或網域。請參考下表:
| 主體 | 範例使用者帳戶 |
|---|---|
| 單一使用者 | user@gmail.com |
| Google 群組 | admins@googlegroups.com |
| Google Workspace 網域 | example.com |
撤銷執行階段範本的存取權
如要撤銷執行階段範本的存取權,可以使用 Google Cloud 控制台或 gcloud CLI。
控制台
前往 Google Cloud 控制台的「IAM」(身分與存取權管理) 頁面。
選取專案、資料夾或組織。
找出要撤銷存取權的主體所在資料列。然後按一下該列中的「 編輯主體」。
按一下要撤銷的角色對應的「Delete」(刪除) 按鈕,然後按一下「Save」(儲存)。
gcloud
使用下列任何指令資料前,請先替換以下項目:
RUNTIME_TEMPLATE_ID:執行階段範本的 ID。PRINCIPAL:要撤銷存取權的主體。ROLE:要從主體移除的角色。PROJECT_ID:您的專案 ID。REGION:執行階段範本所在的區域。
執行下列指令:
Linux、macOS 或 Cloud Shell
gcloud colab runtime-templates remove-iam-policy-binding RUNTIME_TEMPLATE_ID \ --member=PRINCIPAL \ --role=ROLE \ --project=PROJECT_ID \ --region=REGION
Windows (PowerShell)
gcloud colab runtime-templates remove-iam-policy-binding RUNTIME_TEMPLATE_ID ` --member=PRINCIPAL ` --role=ROLE ` --project=PROJECT_ID ` --region=REGION
Windows (cmd.exe)
gcloud colab runtime-templates remove-iam-policy-binding RUNTIME_TEMPLATE_ID ^ --member=PRINCIPAL ^ --role=ROLE ^ --project=PROJECT_ID ^ --region=REGION
如要進一步瞭解如何透過指令列管理執行階段範本的 IAM 政策,請參閱 gcloud CLI 說明文件。
後續步驟
- 如要瞭解如何授予筆記本存取權,請參閱「管理筆記本存取權」。