啟用即時電子郵件和即時通訊通知

總覽

Security Command Center 會在Google Cloud 控制台中即時通知您發現項目。本指南說明如何使用 Google Cloud 服務和第三方 API 擴充功能,並透過電子郵件和即時通訊應用程式接收近乎即時的通知。完成指南後,您不必登入 Google Cloud 控制台,即可接收已設定第三方服務的新發現快訊,加快處理安全漏洞和威脅的速度。進一步瞭解 Security Command Center 中的各種安全漏洞和威脅

拓撲

在本指南中,您會建立如下圖所示的設定。

近乎即時的通知工作流程 (點選即可放大)
Security Command Center 的近乎即時通知工作流程 (按一下即可放大)

目標

在本指南中,您將執行下列操作:

  1. 設定 Pub/Sub 主題。
  2. 設定 Slack、WebEx Teams 和 Twilio SendGrid Mail。
  3. 在 Cloud Run functions 中編寫程式碼。
  4. 設定 Pub/Sub 和 Cloud Run 函式,在有新的高嚴重性或重大嚴重性發現項目寫入 Security Command Center 時,傳送通知給 Slack、WebEx Teams 或 Twilio Sendgrid Mail。
  5. 排解通知問題。

費用

本教學課程使用 Google Cloud的計費元件,包括:

  • Pub/Sub
  • Cloud Run 函式
  • Cloud Build

使用 Pricing Calculator,根據您的預測使用量來產生預估費用。

事前準備

如要完成本指南,您必須具備下列 Identity and Access Management (IAM) 角色:

  • 機構管理員 (roles/resourcemanager.organizationAdmin)
  • 安全中心管理員 (roles/securitycenter.admin)
  • 安全性管理員 (roles/iam.securityAdmin)
  • 具有 serviceusage.services.use 權限的角色,例如擁有者 (roles/owner)、編輯者 (roles/editor) 或自訂角色
  • 建立服務帳戶 (roles/iam.serviceAccountCreator)
  • Pub/Sub 編輯者 (roles/pubsub.editor)
  • 帳單帳戶管理員 (roles/billing.admin)

您可以在機構、資料夾或專案層級授予 Security Command Center 的 IAM 角色。您能否查看、編輯、建立或更新發現項目、資產和安全性來源,取決於您獲准的存取層級。如要進一步瞭解 Security Command Center 角色,請參閱存取權控管

設定專案

請按照下列步驟建立或選取專案。

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Cloud Build API.

    Enable the API

  5. Install the Google Cloud CLI.

  6. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  7. To initialize the gcloud CLI, run the following command:

    gcloud init
  8. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  9. Make sure that billing is enabled for your Google Cloud project.

  10. Enable the Cloud Build API.

    Enable the API

  11. Install the Google Cloud CLI.

  12. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  13. To initialize the gcloud CLI, run the following command:

    gcloud init
  14. 預估時間:為單一服務設定及測試通知約需一小時。

    設定 Pub/Sub 主題

    Pub/Sub 是一項即時訊息傳遞服務,可在不同應用程式之間收發訊息。進一步瞭解 Pub/Sub

    在本節中,您要設定 Security Command Center,將發現項目發布至 Pub/Sub 主題。

    如要設定及訂閱 Pub/Sub 主題,請按照下列步驟操作:

    1. 在環境變數中指定 Google Cloud 專案。

      export PROJECT_ID=PROJECT_ID
      

      PROJECT_ID 替換為您的專案 ID。

    2. 在環境變數中指定 Google Cloud 機構。

      export ORG_ID=ORG_ID
      

      ORG_ID 替換為機構 ID。

    3. 設定 gcloud 指令的專案 ID。

      gcloud config set project PROJECT_ID
      
    4. 建立發布通知的 Pub/Sub 主題。

      gcloud pubsub topics create scc-critical-and-high-severity-findings-topic
      
    5. 在環境變數中指定主題。

      export TOPIC=projects/$PROJECT_ID/topics/scc-critical-and-high-severity-findings-topic
      
    6. 建立訂閱項目,在訊息發布至主題時通知 Cloud Run 函式傳送電子郵件或即時通訊訊息。

      gcloud pubsub subscriptions create scc-critical-and-high-severity-findings-sub \
        --topic scc-critical-and-high-severity-findings-topic
      
    7. 設定 Security Command Center,將通知發布至該主題。您可以使用任何與 ListFindings API 相容的篩選條件。

      下列篩選器會針對 global 位置中嚴重程度為高和重大的有效發現項目,發布通知。進一步瞭解如何篩選發現項目

       gcloud scc notifications create scc-critical-high-severity \
           --pubsub-topic=$TOPIC \
           --organization=$ORG_ID \
           --location=global \
           --filter "(severity=\"HIGH\" OR severity=\"CRITICAL\") AND state=\"ACTIVE\""
      

    接著,您要建立或設定電子郵件或即時通訊應用程式,接收來自 Pub/Sub 的通知。

    設定訊息應用程式

    本節說明如何使用 Pub/Sub 和 Cloud Run 函式或 Cloud Run 函式 (第 1 代),為 Twilio Sendgrid Mail API、Slack 和 WebEx Teams 啟用近乎即時的通知。

    Twilio Sendgrid Mail

    如要啟用電子郵件通知,請按照下列步驟操作:

    • 建立 Twilio Sendgrid Mail API 帳戶,並取得 API 金鑰。
    • 建立及部署 Cloud Run 函式,在收到 Pub/Sub 通知時傳送電子郵件。

    建立 Twilio Sendgrid Mail API 帳戶

    在本節中,您將建立 Twilio Sendgrid Mail API 帳戶,並取得 API 金鑰。如果已啟用 SendGrid,請跳至「取得 Twilio Sendgrid Mail API 金鑰」,並確認現有 API 金鑰具備足夠權限。

    1. 前往 Google Cloud 控制台。
      前往 Google Cloud 控制台
    2. 在頁面頂端的搜尋框中,搜尋「SendGrid Email API」SendGrid 搜尋
    3. 在下一頁中,選取符合需求的方案。

      • 免費方案每月最多可傳送 12,000 封電子郵件,足以滿足本指南的需求,但大型機構可能需要更多。如果預期會收到大量電子郵件通知,請考慮在通知中新增篩選條件,排除雜訊發現項目。
      • 系統可能會要求您選取要與 SendGrid 建立關聯的專案。 選取專案以繼續操作。您可能需要足夠的權限,才能管理專案相關聯帳單帳戶的購買交易。
    4. 詳閱條款,確認沒有問題後,按一下「訂閱」

    5. 按一下「向 SendGrid 註冊」,啟用 SendGrid 服務。

    6. 在註冊畫面中輸入使用者名稱、密碼和電子郵件地址。 接受服務條款,然後按一下「繼續」

    7. 在確認對話方塊中,按一下「返回 Google」

    取得 Twilio Sendgrid Mail API 金鑰

    1. 按一下「在 SendGrid 網站上管理 API 金鑰」。系統會開啟新的分頁,顯示 SendGrid 網站。 管理 API 金鑰

    2. 填寫表單或登入帳戶 (如果系統提示)。然後按一下「開始使用!」

    3. 在選單面板中展開「設定」,然後按一下「API 金鑰」

    4. 在下一個畫面中,按一下「建立 API 金鑰」按鈕。

    5. 在「API Key Name」下方,輸入「SCC Email Notifications」,選取「Full Access」,然後按一下「Create & View」按鈕。

      API 金鑰名稱

    6. 系統會顯示 API 金鑰。請記下該值。下一節會用到這項資訊。

    7. 按一下 [完成]。系統會顯示目前的 API 金鑰組合。關閉分頁,然後返回 Google Cloud 控制台。

    接著,您會部署 Cloud Run 函式,將通知傳送至電子郵件地址。

    建立 SendGrid Cloud Run 函式

    在本節中,您將部署函式,將通知傳送至您的電子郵件帳戶。

    1. 前往 Cloud Run functions。
      前往 Cloud Run functions

    2. 請確認您使用的 PROJECT_ID 與建立 Pub/Sub 主題時相同。

    3. 按一下「建立函式」SendGrid 函式

    4. 將「Function name」(函式名稱) 設為 send-high-and-critical-finding-email-notification,並將「Trigger type」(觸發條件類型) 設為「Pub/Sub」

    5. 選取您在「設定 Pub/Sub 主題」中建立的 Pub/Sub 主題。

    6. 依序點選「儲存」和「下一步」

    7. 在下一個頁面中,將「執行階段」設為「Python 3.8」。本節的程式碼範例是以 Python 編寫,但您可以使用 Cloud Run 函式支援的任何語言。

    8. 在檔案清單中,按一下「requirements.txt」requirements.txt,然後在文字欄位中新增以下內容:sendgrid

      SendGrid 需求條件

    9. 點選「main.py」main.py,然後將內容替換為下列程式碼片段。

      import base64
      import json
      from sendgrid import SendGridAPIClient
      from sendgrid.helpers.mail import Mail
      
      def send_email_notification(event, context):
          """Triggered from a message on a Pub/Sub topic.
          Args:
               event (dict): Event payload.
               context (google.cloud.functions.Context): Metadata for the event.
          """
          pubsub_message = base64.b64decode(event['data']).decode('utf-8')
          message_json = json.loads(pubsub_message)
          message = Mail(
              from_email='noreply@yourdomain.com',
              to_emails='$EMAIL_ADDRESS',
              subject='New High or Critical Severity Finding Detected',
              html_content='A new high or critical severity finding was
              detected: ' + ''.join(message_json['finding']['category']))
          try:
              sg = SendGridAPIClient('$SENDGRID_EMAIL_API_KEY')
              response = sg.send(message)
              print(response.status_code)
              print(response.body)
              print(response.headers)
          except Exception as e:
              print(e)
      
          print(pubsub_message)
      
    10. 更改下列內容:

      • noreply@yourdomain.com 變更為您要用來發送郵件的電子郵件地址。
      • $EMAIL_ADDRESS變更為預期收件者的電子郵件地址。 注意:這個變數可以保存電子郵件地址陣列 (['user1@yourdomain.com', 'user2@yourdomain.com']),也可以編寫自訂程式碼,將動態變數設為輪流值班人員清單等。
      • $SENDGRID_EMAIL_API_KEY 變更為現有的 API 金鑰,或上一節中建立的 API 金鑰。
    11. 前往「Entry point」(進入點) 欄位,然後在程式碼片段中輸入函式名稱 (在本範例中為 send_email_notification)。

    12. 按一下「Deploy」(部署)。系統會將您帶回 Cloud Run 函式清單,您應該會看到新的函式。函式名稱旁出現綠色勾號時,即表示部署成功。這個程序可能需要幾分鐘。 部署 SendGrid 函式

    Slack

    如要將通知傳送至 Slack 頻道,請按照下列步驟操作:

    • 建立新的 Slack 應用程式,並授予足夠的權限,以便將訊息發布至公開 Slack 頻道。
    • 建立及部署 Cloud Run 函式,在收到 Pub/Sub 通知時,將即時通訊訊息發布到 Slack。

    建立新的 Slack 應用程式

    在本節中,您將建立新的 Slack 應用程式來接收通知。

    1. 前往 Slack API 應用程式。 系統會在新分頁中開啟該頁面。
    2. 登入或建立帳戶。

    3. 選取「建立應用程式」

    4. 將「應用程式名稱」設為「SCC Finding Notifier」

    5. 選取要讓 Slack 機器人發布訊息的開發 Slack 工作區,然後按一下「建立應用程式」

    6. 在導覽面板中,選取「OAuth 和權限」

      Slack 權限

    7. 前往「範圍」部分。範圍分為兩類:

      • 機器人權杖範圍
      • 使用者權杖範圍
    8. 在本練習中,您不需要新增使用者權杖範圍。在「機器人權杖範圍」下方,按一下「新增 OAuth 範圍」,然後輸入:

      • chat:write
      • chat:write.public

        Slack 範圍
    9. 捲動至「OAuth 和權限」頁面頂端,然後按一下「將應用程式安裝到 Workspace」

    10. 在確認對話方塊中,按一下「允許」

    11. 複製 Bot User OAuth Access Token,以便在 Cloud Function 中使用。

    接著,您會部署 Cloud Run 函式,將通知傳送至 Slack 群組。

    建立 Slack Cloud Run 函式

    在本節中,您將部署函式,以便將通知傳送至 Slack 帳戶。

    1. 前往 Cloud Run functions。
      前往 Cloud Run functions

    2. 請確認您使用的 PROJECT_ID 與建立 Pub/Sub 主題時使用的相同。

    3. 按一下「建立函式」SendGrid 函式

    4. 將「Function name」(函式名稱) 設為 slack-chat-high-and-critical-findings,並將「Trigger type」(觸發條件類型) 設為「Pub/Sub」

    5. 選取您在「設定 Pub/Sub 主題」中建立的 Pub/Sub 主題。

    6. 依序點選「儲存」和「下一步」

    7. 在下一個頁面中,將「執行階段」設為「Python 3.8」。本節的程式碼範例是以 Python 編寫,但您可以使用 Cloud Run 函式支援的任何語言。

    8. 前往檔案清單。按一下 requirements.txt,然後新增以下內容:requestsSlack 需求

    9. 點選「main.py」main.py,並將內容替換為下列程式碼片段。

      import base64
      import json
      import requests
      
      TOKEN = "BOT_ACCESS_TOKEN"
      
      def send_slack_chat_notification(event, context):
          pubsub_message = base64.b64decode(event['data']).decode('utf-8')
          message_json = json.loads(pubsub_message)
          finding = message_json['finding']
      
          requests.post("https://slack.com/api/chat.postMessage", data={
              "token": TOKEN,
              "channel": "#general",
              "text": f"A high severity finding {finding['category']} was detected!"
          })
      
    10. BOT_ACCESS_TOKEN 替換為您使用 Slack 應用程式建立的機器人使用者 OAuth 存取權杖

    11. 前往「Entry point」(進入點) 欄位,然後在程式碼片段中輸入函式名稱 (在本例中為 send_slack_chat_notification)。

    12. 按一下「Deploy」(部署)。系統會將您帶回 Cloud Run 函式清單,您應該會看到新的函式。函式名稱旁顯示綠色勾號時,即表示部署成功。這項程序可能需要幾分鐘才能完成。訊息會顯示在 #general Slack 頻道中。 Slack 函式

    WebEx

    如要將通知傳送至 WebEx Teams 帳戶,請按照下列步驟操作:

    • 建立新的服務帳戶,並授予從 Security Command Center 擷取資產的權限。
    • 建立新的 WebEx 機器人,並授予足夠的權限,以便在工作區中發布訊息。
    • 建立及部署 Cloud Run 函式,訂閱 Pub/Sub 並在收到 Pub/Sub 主題的通知時,將即時通訊訊息發布至 WebEx。

    建立服務帳戶

    根據預設,Cloud Run 函式無法從 Security Command Center 擷取資產。在本節中,您會佈建服務帳戶,允許 Cloud Run 函式擷取與發現項目相關聯的資產。

    1. 為服務帳戶命名,並指定為環境變數。

      export SERVICE_ACCOUNT=ACCOUNT_NAME
      
    2. 為專案建立服務帳戶。

      gcloud iam service-accounts create $SERVICE_ACCOUNT \
       --display-name "Service Account for SCC Finding Notifier WebEx Cloud Function" \
       --project $PROJECT_ID
      
    3. 機構層級將 securitycenter.assetsViewer 角色授予服務帳戶。

       gcloud organizations add-iam-policy-binding $ORG_ID \
         --member="serviceAccount:$SERVICE_ACCOUNT@$PROJECT_ID.iam.gserviceaccount.com" \
         --role='roles/securitycenter.assetsViewer'
      

    建立 Webex 機器人

    在本節中,您將建立 WebEx 機器人,以便在工作區中發布訊息。

    1. 登入 WebEx Teams 帳戶,然後前往「New Bot」頁面。

    2. 將「Bot Name」(機器人名稱) 設為「SCC Finding Notifier」(SCC 發現事項通知器)

    3. 選取描述性但獨特的機器人使用者名稱 (your-name-scc-finding-notifier-demo)。

    4. 在「圖示」下方選取「預設 1」

    5. 將「Description」設為「A bot that notifies the team when a new high or critical severity finding is published to Security Command Center.」(機器人會在 Security Command Center 發布新的高嚴重程度或重大嚴重程度發現項目時通知團隊)。

    6. 按一下「新增機器人」

    7. 在確認頁面中,複製「Bot Access Token」並儲存,以供 Cloud Run 函式使用。

    將 Webex 機器人新增至工作區

    在本節中,您將 WebEx 機器人新增至工作區。

    1. 在要讓機器人發布通知的 WebEx Space 中,展開活動面板。 WebEx 面板

    2. 選取「新增邀請對象」

    3. 在文字欄位中輸入「SCC Finding Notifier」,然後從下拉式選單中選取您建立的機器人。 WebEx 附加元件

    4. 選取「新增」按鈕,然後關閉面板。

    5. 取得 Cloud Run 函式的工作區 Room ID。 在桌上型電腦上前往 https://developer.webex.com/docs/api/v1/rooms/list-rooms,並視需要登入。本頁面使用 WebEx API 列出您所屬的會議室。WebEx 房間

    6. 前往搜尋面板。

    7. 選取面板頂端的「試用」分頁標籤。

    8. 所有選項都保留預設值,然後點選「執行」

    9. 在「Response」分頁中,您會收到 JSON 格式的回應,其中包含 items 或會議室清單。找出要顯示通知的房間 title,並記錄相關聯的 id 值。WebEx
response

    接著,您會部署 Cloud Run 函式,將通知傳送至 WebEx 工作區。

    建立 WebEx Cloud Run 函式

    在本節中,您將部署函式,以便將通知傳送至 WebEx 帳戶。

    1. 前往 Cloud Run functions。
      前往 Cloud Run functions

    2. 選取建立 Pub/Sub 主題的相同 PROJECT_ID

    3. 按一下「建立函式」WebEx 函式

    4. 將「Function name」(函式名稱) 設為 webex-teams-high-and-critical-findings,並將「Trigger type」(觸發條件類型) 設為「Pub/Sub」

    5. 選取您在「設定 Pub/Sub 主題」中建立的 Pub/Sub 主題。

    6. 展開「變數、網路及進階設定」欄位。

    7. 在「Service account」(服務帳戶) 下方,篩選並選取您建立的 webex-cloud-function-sa 服務帳戶。WebEx 變數

    8. 依序點選「儲存」和「下一步」

    9. 在下一個頁面中,將「執行階段」設為「Python 3.8」。本節的程式碼範例是以 Python 編寫,但您可以使用 Cloud Run 函式支援的任何語言。

    10. 前往檔案清單。點選「requirements.txt」requirements.txt,然後新增下列內容:

      • requests==2.25.1
      • google-cloud-securitycenter==1.1.0 WebEx 需求
    11. 點選「main.py」main.py,然後將內容替換為下列程式碼片段。

      #!/usr/bin/env python3
      import base64
      import json
      
      import requests
      from google.cloud import securitycenter_v1
      
      WEBEX_TOKEN = "WEBEX_TOKEN"
      ROOM_ID = "ROOM_ID"
      
      TEMPLATE = """
      **Severity:** {severity}\n
      **Asset:** {asset}\n
      **SCC Category:** {category}\n
      **Project:** {project}\n
      **First observed:** {create_time}\n
      **Last observed:** {event_time}\n
      **Link to finding:** {finding_link}
      """
      
      PREFIX = "https://console.cloud.google.com/security/command-center/findings"
      
      def get_finding_detail_page_link(finding_name):
          """Constructs a direct link to the finding detail page."""
          org_id = finding_name.split("/")[1]
          return f"{PREFIX}?organizationId={org_id}&resourceId={finding_name}"
      
      def get_asset(parent, resource_name):
          """Retrieves the asset corresponding to `resource_name` from SCC."""
          client = securitycenter_v1.SecurityCenterClient()
          resp = client.list_assets(
              securitycenter_v1.ListAssetsRequest(
                  parent=parent,
                  filter=f'securityCenterProperties.resourceName="{resource_name}"',
              )
          )
          page = next(resp.pages)
          if page.total_size == 0:
              return None
          asset = page.list_assets_results[0].asset
          return json.loads(securitycenter_v1.Asset.to_json(asset))
      
      def send_webex_teams_notification(event, context):
          """Send the notification to WebEx Teams."""
          pubsub_message = base64.b64decode(event["data"]).decode("utf-8")
          message_json = json.loads(pubsub_message)
          finding = message_json["finding"]
      
          parent = "/".join(finding["parent"].split("/")[0:2])
          asset = get_asset(parent, finding["resourceName"])
      
          requests.post(
              "https://webexapis.com/v1/messages",
              json={
                  "roomId": ROOM_ID,
                  "markdown": TEMPLATE.format(
                      severity=finding["severity"],
                      asset=asset["securityCenterProperties"]["resourceDisplayName"],
                      category=finding["category"],
                      project=asset["resourceProperties"]["project"],
                      create_time=finding["createTime"],
                      event_time=finding["eventTime"],
                      finding_link=get_finding_detail_page_link(finding["name"]),
                  ),
              },
              headers={"Authorization": f"Bearer {WEBEX_TOKEN}"},
          )
      
    12. 更改下列內容:

      • WEBEX_TOKEN,並使用「建立 WebEx 機器人」一節中的機器人存取權杖。
      • ROOM_ID,並使用「將 WebEx 機器人新增至工作區」部分中的聊天室 ID。
    13. 前往「Entry point」(進入點) 欄位,然後在程式碼片段中輸入函式名稱 (在本例中為 send_webex_teams_notification)。

    14. 按一下「Deploy」(部署)。系統會將您帶回 Cloud Run 函式清單,您應該會看到新的函式。函式名稱旁出現綠色勾號時,即表示部署成功。這項程序可能需要幾分鐘。 WebEx 部署

    如果所選服務的前述步驟順利完成,即表示設定完成,您會開始收到通知。注意事項:

    • 系統會針對每個重大或高度嚴重性發現事項,分別傳送電子郵件或即時通訊訊息給您。通知頻率或數量取決於貴機構的資源。
    • 系統會近乎即時地發布及傳送通知。不過,系統不保證能即時傳送電子郵件或訊息,且多種因素都可能導致延遲,包括 Twilio Sendgrid Mail、電子郵件系統、Slack 或 WebEx 發生問題。

    如要變更通知工作流程,請按照下列步驟操作:

    • 如要變更收件者,請更新 Cloud Run 函式。
    • 如要變更會觸發通知的發現項目,請更新 Pub/Sub 主題的篩選條件。

    測試通知

    如要測試通知是否已正確設定,請按照下列操作說明,將高嚴重程度的發現項目切換為有效和無效狀態。

    1. 前往 Security Command Center 發現項目頁面。
      前往「發現項目」頁面
    2. 如果系統提示,請選取機構。
    3. 在「快速篩選器」面板中,向下捲動至「嚴重程度」部分,然後選取「高」或「重大」。「Findings query results」(發現項目查詢結果) 面板會更新,只顯示所選嚴重程度的發現項目。
    4. 在「發現項目查詢結果」面板中,勾選發現項目名稱旁的方塊,選取要查看的項目。
    5. 在「發現項目查詢結果」動作列的「變更有效狀態」選單中,選取「無效」。如果目前的發現項目查詢只顯示有效發現項目,該發現項目就會從查詢結果中移除。
    6. 在「快速篩選器」面板中,向下捲動至「狀態」部分,然後變更選取項目,只選取「無效」。「發現項目查詢結果」面板會更新,只顯示已停用的發現項目。
    7. 在「發現項目查詢結果」面板中,選取您標示為無效的發現項目。
    8. 在「發現項目查詢結果」動作列中,選取「變更有效狀態」選單中的「有效」
    9. 檢查電子郵件或訊息服務,您應該會看到類似下圖的訊息。

    電子郵件:

    電子郵件通知

    Slack:

    Slack 通知

    傳送至 WebEx 的訊息 (本指南中提供更多資訊) 類似於下圖。

    WebEx 通知

    疑難排解

    如果無法傳送或接收電子郵件或即時通訊訊息,請按照下列步驟找出並解決潛在問題。

    • Twilio Sendgrid Mail:

      • 如要避免電子郵件移至垃圾郵件資料夾,請將 from_email 值加入電子郵件許可清單,或在 SendGrid 上設定寄件者驗證
      • 請確認您未超出 SendGrid 方案的速率限制。
      • 您可以透過 SendGrid 報表偵測傳送失敗的電子郵件。
        • 網域或電子郵件服務供應商的 DMARC 政策可能會封鎖來自未經驗證寄件者的電子郵件。瞭解 SendGrid 如何管理寄件者身分。 如有錯誤,請嘗試使用from_email 值中的其他電子郵件地址。
    • Twilio Sendgrid Mail、Slack 和 WebEx:

      1. 檢查 Cloud Run 函式的 Stackdriver 記錄,判斷函式是否遭到叫用。如果沒有叫用,請確認通知設定正確無誤。

      2. 如果叫用的是 Cloud Run 函式,則函式可能當機。使用 Google Cloud 控制台的 Error Reporting 檢查 Cloud Run 函式是否有錯誤。

    正在清除所用資源

    如要避免系統向您的 Google Cloud 帳戶收取本教學課程所用資源的費用,請刪除含有相關資源的專案,或者保留專案但刪除個別資源。

    刪除專案

    1. In the Google Cloud console, go to the Manage resources page.

      Go to Manage resources

    2. In the project list, select the project that you want to delete, and then click Delete.
    3. In the dialog, type the project ID, and then click Shut down to delete the project.

    刪除個別資源

    1. 刪除通知設定:

      gcloud scc notifications delete scc-critical-high-severity \
          --organization=ORG_ID \
          --location=global
      

      ORG_ID 替換為機構 ID。

      如要保留設定並暫時停止接收通知,請在 Cloud Run 函式中註解掉 sendpost 呼叫。

    2. 刪除 Cloud Run 函式:

      1. 前往 Cloud Run functions。
        前往 Cloud Run functions
      2. 按一下要刪除函式旁邊的核取方塊。
      3. 按一下「刪除」圖示
    3. 刪除服務帳戶:

      1. 前往「Service accounts」(服務帳戶) 頁面。
        前往「Service accounts」(服務帳戶) 頁面
      2. 選取專案。
      3. 選取要刪除的服務帳戶,然後按一下「刪除」圖示

    後續步驟