雲端淘汰和重大變更一般建議

雲端淘汰和重大變更一般建議工具會提供雲端淘汰和重大變更相關建議。這項功能會找出即將淘汰的雲端資源,以及即將發生的重大變更,並提供管理這些資源的指南。您可以透過 Google Cloud CLI、API 和 BigQuery Export 查看建議。

事前準備

  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.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Recommender 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

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. Enable the Recommender 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

    1. 請確認您具備下列角色:
    說明 角色
    查看建議 recommender.cloudDeprecationRecommendationViewer
    查看及更新建議 recommender.cloudDeprecationRecommendationAdmin

    必要的角色

    本節說明使用雲端淘汰和重大變更一般建議所需的角色和權限。

    角色 包含的權限
    roles/recommender.cloudDeprecationRecommendationViewer
    • recommender.cloudDeprecationGeneralInsights.get
    • recommender.cloudDeprecationGeneralInsights.list
    • recommender.cloudDeprecationGeneralRecommendations.get
    • recommender.cloudDeprecationGeneralRecommendations.list
    roles/recommender.cloudDeprecationRecommendationAdmin
    • recommender.cloudDeprecationGeneralInsights.update
    • recommender.cloudDeprecationGeneralRecommendations.update

    如要進一步瞭解角色和授予存取權的方法,請參閱下列文章:

    定價

    雲端淘汰和重大變更一般建議工具免費提供。如要瞭解其他定價層級,請參閱「Recommender 定價」。

    查看雲端淘汰建議

    您可以使用控制台、Google Cloud CLI、Recommender API 或 BigQuery 匯出功能,列出建議。

    主控台

    1. 前往建議中心

      前往建議中心

    2. 將「篩選器欄位」設為 Recommender:google.cloud.deprecation.GeneralRecommender

    Google Cloud CLI

    這個分頁會顯示使用 Google Cloud CLI 列出建議和洞察資料的指令。

    • 列出建議

      gcloud recommender recommendations list \
        --billing-project=BILLING_PROJECT_ID  \
        --project=PROJECT_ID  \
        --location=LOCATION  \
        --recommender=google.cloud.deprecation.GeneralRecommender \
        --format=yaml
      
    • 列出洞察資訊

      gcloud recommender insights list \
        --billing-project=BILLING_PROJECT_ID  \
        --project=PROJECT_ID  \
        --location=LOCATION  \
        --insight-type=google.cloud.deprecation.GeneralInsight \
        --format=yaml
      

    更改下列內容:

    • BILLING_PROJECT_ID,並將其替換為已啟用 Recommender API 的專案 ID。
    • PROJECT_ID 替換為 Google Cloud 專案的 ID。
    • LOCATION 建議相關聯資源所在的位置 (例如 global 或 us-central1-a)。 Google Cloud

    API

    這個分頁會顯示使用 Recommender API 列出建議和洞察資料的指令。

    • 可列出建議

      curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      -H "x-goog-user-project: BILLING_PROJECT_ID " \
      "https://recommender.googleapis.com/v1/projects/PROJECT_ID /locations/LOCATION /recommenders/google.cloud.deprecation.GeneralRecommender/recommendations"
      
    • 列出洞察資訊

      curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      -H "x-goog-user-project: BILLING_PROJECT_ID " \
      "https://recommender.googleapis.com/v1/projects/PROJECT_ID /locations/LOCATION /insightTypes/google.cloud.deprecation.GeneralInsight/insights"
      

    更改下列內容:

    • BILLING_PROJECT_ID,並將其替換為已啟用 Recommender API 的專案 ID。
    • PROJECT_ID 替換為 Google Cloud 專案的 ID。
    • LOCATION 建議相關聯資源所在的位置 (例如 global 或 us-central1-a)。 Google Cloud

    BigQuery 匯出內容

    這個分頁會顯示指令,列出透過 BigQuery 匯出功能取得的建議。

    匯出至 BigQuery 的資料也會包含 Cloud 淘汰建議。透過 BigQuery 匯出功能,您可以查看機構每日的建議快照。

    1. 請按照 BigQuery 匯出說明文件,將建議匯出至 BigQuery。

    2. 查詢所有淘汰建議:

      SELECT *
      FROM `<project>.<dataset>.recommendations_export`
      WHERE DATE(_PARTITIONTIME) = "<date>"
      and recommender = "google.cloud.deprecation.GeneralRecommender"
      

    可用的建議子類型

    下表說明可用的建議子類型,以及是否可揭露。

    子類型 停用或破壞性變更?
    GCE_METADATA_SERVER_HEADER_WHITESPACE 為符合 RFC 7230 第 3.2 節的規定,Compute Engine 會在 Compute Engine 中繼資料服務中強制執行 HTTP 要求格式檢查,因為接受格式錯誤的要求可能會導致安全漏洞。

    請注意,這份表格並不完整,且可能刻意省略安全性相關的淘汰或重大變更。