刪除訂閱項目 SMT

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

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

必要角色和權限

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

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

所需權限

如要刪除訂閱項目 SMT,您必須具備下列權限:

  • 授予訂閱項目的「刪除訂閱項目」權限: pubsub.subscriptions.delete
  • 授予查看專案訂閱權限。只有在使用 Google Cloud 控制台時,才需要這項權限: pubsub.subscriptions.view

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

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

刪除訂閱項目 SMT

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

控制台

  1. 在 Google Cloud 控制台中,前往 Pub/Sub 的「Subscriptions」 頁面。

    前往「訂閱項目」頁面

  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 subscriptions update 指令:

    gcloud pubsub subscriptions update SUBSCRIPTION_ID \
        --clear-message-transforms

    更改下列內容:

    • SUBSCRIPTION_ID:要更新的訂閱項目 ID 或名稱。

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

後續步驟