使用 IAM 进行访问权限控制

如需限制项目或组织内用户的访问权限,您可以为 Dataflow 使用 Identity and Access Management (IAM) 角色。您可以控制对 Dataflow 相关资源的访问权限,而不是向用户授予整个 Google Cloud 项目的 Viewer、Editor 或 Owner 角色。

本页重点介绍了如何使用 Dataflow 的 IAM 角色。如需详细了解 IAM 及其功能,请参阅 IAM 文档

每种 Dataflow 方法都要求调用者拥有必要的权限。有关 Dataflow 支持的权限和角色的列表,请参阅以下部分。

权限和角色

本部分汇总了 Dataflow IAM 支持的权限和角色。

所需权限

下表列出了调用者调用每种方法必须具备的权限:

方法 所需权限
dataflow.jobs.create dataflow.jobs.create
dataflow.jobs.cancel dataflow.jobs.cancel
dataflow.jobs.updateContents dataflow.jobs.updateContents
dataflow.jobs.list dataflow.jobs.list
dataflow.jobs.get dataflow.jobs.get
dataflow.messages.list dataflow.messages.list
dataflow.metrics.get dataflow.metrics.get
dataflow.jobs.snapshot dataflow.jobs.snapshot

角色

下表列出了 Dataflow IAM 角色,还有一个列表列出每个角色包含的 Dataflow 相关权限。每个权限适用于特定的资源类型。如需查看权限列表,请参阅 Google Cloud 控制台中的角色页面

Role Permissions

(roles/dataflow.admin)

Minimal role for creating and managing dataflow jobs.

cloudbuild.builds.create

cloudbuild.builds.get

cloudbuild.builds.list

cloudbuild.builds.update

cloudbuild.operations.*

  • cloudbuild.operations.get
  • cloudbuild.operations.list

compute.machineTypes.get

compute.projects.get

compute.regions.list

compute.zones.list

dataflow.jobs.*

  • dataflow.jobs.cancel
  • dataflow.jobs.create
  • dataflow.jobs.get
  • dataflow.jobs.list
  • dataflow.jobs.snapshot
  • dataflow.jobs.updateContents

dataflow.messages.list

dataflow.metrics.get

dataflow.snapshots.*

  • dataflow.snapshots.delete
  • dataflow.snapshots.get
  • dataflow.snapshots.list

recommender.dataflowDiagnosticsInsights.*

  • recommender.dataflowDiagnosticsInsights.get
  • recommender.dataflowDiagnosticsInsights.list
  • recommender.dataflowDiagnosticsInsights.update

remotebuildexecution.blobs.get

resourcemanager.projects.get

resourcemanager.projects.list

storage.buckets.get

storage.objects.create

storage.objects.get

storage.objects.list

(roles/dataflow.developer)

Provides the permissions necessary to execute and manipulate Dataflow jobs.

Lowest-level resources where you can grant this role:

  • Project

cloudbuild.builds.create

cloudbuild.builds.get

cloudbuild.builds.list

cloudbuild.builds.update

cloudbuild.operations.*

  • cloudbuild.operations.get
  • cloudbuild.operations.list

compute.projects.get

compute.regions.list

compute.zones.list

dataflow.jobs.*

  • dataflow.jobs.cancel
  • dataflow.jobs.create
  • dataflow.jobs.get
  • dataflow.jobs.list
  • dataflow.jobs.snapshot
  • dataflow.jobs.updateContents

dataflow.messages.list

dataflow.metrics.get

dataflow.snapshots.*

  • dataflow.snapshots.delete
  • dataflow.snapshots.get
  • dataflow.snapshots.list

recommender.dataflowDiagnosticsInsights.*

  • recommender.dataflowDiagnosticsInsights.get
  • recommender.dataflowDiagnosticsInsights.list
  • recommender.dataflowDiagnosticsInsights.update

remotebuildexecution.blobs.get

resourcemanager.projects.get

resourcemanager.projects.list

(roles/dataflow.viewer)

Provides read-only access to all Dataflow-related resources.

Lowest-level resources where you can grant this role:

  • Project

dataflow.jobs.get

dataflow.jobs.list

dataflow.messages.list

dataflow.metrics.get

dataflow.snapshots.get

dataflow.snapshots.list

recommender.dataflowDiagnosticsInsights.get

recommender.dataflowDiagnosticsInsights.list

resourcemanager.projects.get

resourcemanager.projects.list

(roles/dataflow.worker)

Provides the permissions necessary for a Compute Engine service account to execute work units for a Dataflow pipeline.

Lowest-level resources where you can grant this role:

  • Project

autoscaling.sites.readRecommendations

autoscaling.sites.writeMetrics

autoscaling.sites.writeState

compute.instanceGroupManagers.update

compute.instances.delete

compute.instances.setDiskAutoDelete

dataflow.jobs.get

dataflow.shuffle.*

  • dataflow.shuffle.read
  • dataflow.shuffle.write

dataflow.streamingWorkItems.*

  • dataflow.streamingWorkItems.ImportState
  • dataflow.streamingWorkItems.commitWork
  • dataflow.streamingWorkItems.getData
  • dataflow.streamingWorkItems.getWork
  • dataflow.streamingWorkItems.getWorkerMetadata

dataflow.workItems.*

  • dataflow.workItems.lease
  • dataflow.workItems.sendMessage
  • dataflow.workItems.update

logging.logEntries.create

logging.logEntries.route

monitoring.timeSeries.create

storage.buckets.get

storage.objects.create

storage.objects.get

Dataflow Worker 角色 (roles/dataflow.worker) 可为 Compute Engine 服务账号提供运行 Apache Beam 流水线工作单元所需的权限。Dataflow 工作器角色必须分配给能够从 Dataflow 服务请求和更新工作的服务账号。

Dataflow 服务代理角色 (roles/dataflow.serviceAgent) 仅供 Dataflow 服务账号使用。它为服务账号授予对 Google Cloud 项目中托管资源的访问权限,以运行 Dataflow 作业。当您从 Google Cloud 控制台中的 API 页面为项目启用 Dataflow API 时,系统会自动将其分配给服务账号。

创建作业

要创建作业,roles/dataflow.admin 角色需具备运行和检查作业所需的一组最低权限。

或者,需要具备以下权限:

角色分配示例

为了说明不同 Dataflow 角色的效用,请考虑以下细分讲解:

分配 Dataflow 角色

目前,Dataflow 角色只能在组织和项目级层设置。

要管理组织级层角色,请参阅使用 IAM 对组织进行访问权限控制

要设置项目级层角色,请参阅授予、更改和撤消对资源的访问权限