使用 IAM 控管存取權

Cloud Tasks 使用 Identity and Access Management (IAM) 控管存取權。如要瞭解 IAM 及其功能,請參閱 IAM 總覽。如要瞭解如何授予及撤銷存取權,請參閱「管理專案、資料夾和機構的存取權」一文。

您可以在專案層級和佇列層級設定存取權控管。 舉例來說,您可以授予使用者建立工作並將工作新增到佇列的權限,但不能刪除佇列。或者,您也可以為一組使用者授予專案中所有 Cloud Tasks 資源的存取權。詳情請參閱「安全佇列設定」。

每個 Cloud Tasks 方法都要求呼叫者具備必要的權限。本頁面說明 Cloud Tasks 支援的權限和角色。更新 queue.yamlqueue.xml 時,或使用 Google Cloud 控制台時,系統也會檢查權限。

啟用 Cloud Tasks API

如要查看及指派 Cloud Tasks 的 IAM 角色,您必須為專案啟用 Cloud Tasks API。啟用 API 後,您才能在 Google Cloud 控制台中看到 Cloud Tasks 角色。

主控台

Enable the Cloud Tasks API.

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 API

gcloud

Enable the Cloud Tasks API:

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.

gcloud services enable cloudtasks.googleapis.com

預先定義的角色

下表列出 Cloud Tasks 預先定義的 IAM 角色及其對應權限。

預先定義的角色可因應大多數一般用途。如果預先定義的角色無法滿足您的用途,可以建立 IAM 自訂角色

Role Permissions

(roles/cloudtasks.admin)

Full access to queues and tasks.

cloudtasks.*

  • cloudtasks.cmekConfig.get
  • cloudtasks.cmekConfig.update
  • cloudtasks.locations.get
  • cloudtasks.locations.list
  • cloudtasks.queues.create
  • cloudtasks.queues.delete
  • cloudtasks.queues.get
  • cloudtasks.queues.getIamPolicy
  • cloudtasks.queues.list
  • cloudtasks.queues.pause
  • cloudtasks.queues.purge
  • cloudtasks.queues.resume
  • cloudtasks.queues.setIamPolicy
  • cloudtasks.queues.update
  • cloudtasks.tasks.create
  • cloudtasks.tasks.delete
  • cloudtasks.tasks.fullView
  • cloudtasks.tasks.get
  • cloudtasks.tasks.list
  • cloudtasks.tasks.run

monitoring.timeSeries.list

resourcemanager.projects.get

resourcemanager.projects.list

(roles/cloudtasks.enqueuer)

Access to create tasks.

cloudtasks.tasks.create

cloudtasks.tasks.fullView

resourcemanager.projects.get

resourcemanager.projects.list

(roles/cloudtasks.queueAdmin)

Admin access to queues.

cloudtasks.locations.*

  • cloudtasks.locations.get
  • cloudtasks.locations.list

cloudtasks.queues.*

  • cloudtasks.queues.create
  • cloudtasks.queues.delete
  • cloudtasks.queues.get
  • cloudtasks.queues.getIamPolicy
  • cloudtasks.queues.list
  • cloudtasks.queues.pause
  • cloudtasks.queues.purge
  • cloudtasks.queues.resume
  • cloudtasks.queues.setIamPolicy
  • cloudtasks.queues.update

resourcemanager.projects.get

resourcemanager.projects.list

(roles/cloudtasks.serviceAgent)

Grants Cloud Tasks Service Account access to manage resources.

iam.serviceAccounts.getAccessToken

iam.serviceAccounts.getOpenIdToken

logging.logEntries.create

(roles/cloudtasks.taskDeleter)

Access to delete tasks.

cloudtasks.tasks.delete

resourcemanager.projects.get

resourcemanager.projects.list

(roles/cloudtasks.taskRunner)

Access to run tasks.

cloudtasks.tasks.fullView

cloudtasks.tasks.run

resourcemanager.projects.get

resourcemanager.projects.list

(roles/cloudtasks.viewer)

Get and list access to tasks, queues, and locations.

cloudtasks.cmekConfig.get

cloudtasks.locations.*

  • cloudtasks.locations.get
  • cloudtasks.locations.list

cloudtasks.queues.get

cloudtasks.queues.list

cloudtasks.tasks.fullView

cloudtasks.tasks.get

cloudtasks.tasks.list

monitoring.timeSeries.list

resourcemanager.projects.get

resourcemanager.projects.list

後續步驟