刪除主題 SMT

本文說明如何從現有 Pub/Sub 主題中刪除單一訊息轉換 (SMT)。

如要刪除主題 SMT,您可以使用 Google Cloud 控制台、Google Cloud CLI、用戶端程式庫或 Pub/Sub API。

必要角色和權限

如要取得刪除主題 SMT 所需的權限,請要求管理員為您授予專案的 Pub/Sub 編輯者 (roles/pubsub.editor) 身分與存取權管理角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。

這個預先定義的角色包含刪除主題 SMT 所需的權限。如要查看確切的必要權限,請展開「必要權限」部分:

所需權限

如要刪除主題 SMT,您必須具備下列權限:

  • 授予主題的「更新主題」權限: projects.topics.patch
  • 授予專案的「查看主題」權限。只有在使用 Google Cloud 控制台時,才需要這項權限: pubsub.topics.view

您或許還可透過自訂角色或其他預先定義的角色取得這些權限。

您可以在專案層級和個別資源層級設定存取權控管。

刪除主題 SMT

如要刪除主題 SMT,請按照下列步驟操作:

控制台

  1. 在 Google Cloud 控制台中,前往 Pub/Sub 的「Topics」(主題)頁面。

    前往「主題」

  2. 按一下要刪除 SMT 的主題。

  3. 在主題詳細資料頁面中,按一下「編輯」

    「轉換」分頁會列出與主題相關聯的所有 SMT。

  4. 找出要刪除的 SMT,然後按一下刪除按鈕。

  5. 按一下「更新」

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. 這個指令會刪除與指定主題相關聯的所有 SMT。

    執行加上 --clear-message-transforms 旗標的 gcloud pubsub topics update 指令:

    gcloud pubsub topics update TOPIC_ID --clear-message-transforms

    更改下列內容:

    • TOPIC_ID:要更新的主題 ID 或名稱。

    如要移除單一 SMT,請參閱「更新主題 SMT」,並建立新的 message-transforms-file,其中不包含要刪除的 SMT。

後續步驟