管理对运行时模板的访问权限
本页面介绍了如何在 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 Vertex AI, Dataform, and Compute Engine APIs.
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 Vertex AI, Dataform, and Compute Engine APIs.
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.
所需的角色
如需获得管理对运行时模板的访问权限所需的权限,请让您的管理员为您授予项目的 Colab Enterprise Admin (roles/aiplatform.colabEnterpriseAdmin) IAM 角色。如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。
授予对运行时模板的访问权限
如需向正文授予对运行时模板的访问权限,您可以使用控制台 Google Cloud 、Google Cloud CLI 或 Terraform。
控制台
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 页面。
选择一个项目、文件夹或组织。
找到包含要撤消其访问权限的主账号的行。然后,点击该行中的 修改主账号。
点击要撤消的角色对应的删除 按钮,然后点击保存。
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 文档。
后续步骤
- 如需了解如何授予对笔记本的访问权限,请参阅管理对笔记本的访问权限。