管理对运行时模板的访问权限

本页面介绍了如何在 Colab Enterprise 中授予和撤消对运行时模板的访问权限。

准备工作

  1. 登录您的 Google Cloud 账号。如果您是新手 Google Cloud, 请创建一个账号来评估我们的产品在 实际场景中的表现。新客户还可获享 $300 赠金,用于 运行、测试和部署工作负载。
  2. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. 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 the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  5. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. 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 the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

所需的角色

如需获得管理对运行时模板的访问权限所需的权限,请让您的管理员为您授予项目的 Colab Enterprise Admin (roles/aiplatform.colabEnterpriseAdmin) IAM 角色。如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限

您也可以通过自定义角色或其他预定义角色来获取所需的权限。

授予对运行时模板的访问权限

如需向正文授予对运行时模板的访问权限,您可以使用控制台 Google Cloud 、Google Cloud CLI 或 Terraform。

控制台

  1. 在 Google Cloud 控制台中,前往 Colab Enterprise 运行时模板 页面。

    进入运行时模板

  2. 区域 菜单中,选择包含 您的运行时模板的区域。

  3. 运行时模板 菜单中, 选择一个运行时模板。如果未列出任何运行时模板, 创建 运行时模板

  4. 点击  权限

  5. 权限窗口中,点击  添加 主账号

  6. 授予访问权限 对话框的新的正文 字段中,输入一个或以英文逗号分隔的正文列表。

  7. 选择角色 菜单中,完成对话框 以分配角色。

  8. 可选:点击  添加 其他角色,然后重复上一步。

  9. 点击保存

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。

控制台

  1. 在 Google Cloud 控制台中,前往 IAM 页面。

    转到 IAM

  2. 选择一个项目、文件夹或组织。

  3. 找到包含要撤消其访问权限的主账号的行。然后,点击该行中的 修改主账号

  4. 点击要撤消的角色对应的删除 按钮,然后点击保存

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 文档

后续步骤