クイックスタート: Cloud Location Finder を有効にしてクエリを実行する

このページでは、Google Cloud CLI を使用して Cloud Location Finder を有効にし、近接性、管轄区域、温室効果ガス排出量に基づいてクラウドのロケーションを検索する方法について説明します。ロケーションは、HTTP リクエストまたは Google Cloud CLI コマンドを使用して検索できます。

始める前に

  1. Google Cloud CLI をインストールします。
  2. Google Cloud CLI を初期化するには、次のコマンドを実行します。
    gcloud init
    
  3. Cloud Location Finder API を有効にします。
    gcloud services enable cloudlocationfinder.googleapis.com  --project PROJECT
    
  4. cloudlocationfinder.viewer ロールを追加します。
    gcloud projects add-iam-policy-binding PROJECT \
        --member USER_IDENTIFIER \
        --role roles/cloudlocationfinder.viewer
    
    • PROJECT は、実際のプロジェクト ID に置き換えます。
    • USER_IDENTIFIER は、ユーザー アカウントの識別子に置き換えます。例: user:myemail@example.com
  5. Cloud Location Finder を使用して Google Distributed Cloud コネクテッド ロケーションを検索する場合は、 GDC Hardware Management API を有効にして gdchardwaremanagement.reader ロールを追加します:
    gcloud projects add-iam-policy-binding PROJECT \
        --member USER_IDENTIFIER \
        --role roles/gdchardwaremanagement.reader
    

一般的な Cloud Location Finder クエリを確認する

Cloud Location Finder を使用すると、クラウド ロケーション リポジトリにクエリを実行して、 近接性地域コード、またはGoogle カーボンフリー エネルギー(CFE%) の消費量に基づいて、近くのクラウド ロケーションを特定できます。以降のセクションでは、Cloud Location Finder リポジトリを操作する一般的な例を示します。

Cloud Location Finder は gRPC Transcoding 構文を使用します。

  • PROJECT は、実際のプロジェクト ID に置き換えます。
  • CLOUD_REGION は、クラウド プロバイダの接頭辞を含め、最も近いロケーションを検索するソース クラウド リージョンに置き換えます。 例: gcp-us-central1 または aws-us-east-1
  • CLOUD_PROVIDER は、最も近いロケーションを検索するクラウド プロバイダに置き換えます。例: AWS または GCP

最も近いクラウド ゾーンを見つける

このクエリを使用すると、指定したクラウド プロバイダの近接データを使用して、クラウド ロケーション に最も近いゾーン Google Cloud を特定できます。

HTTP

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "X-Goog-User-Project: PROJECT "https://cloudlocationfinder.googleapis.com/v1alpha/projects/PROJECT/locations/global/cloudLocations:search?source_cloud_location=projects/PROJECT/locations/global/cloudLocations/CLOUD_REGION&query=cloud_provider=CLOUD_PROVIDER_CLOUD_PROVIDER%20AND%20cloud_location_type=CLOUD_LOCATION_TYPE_ZONE&page_size=1"

gcloud

gcloud alpha cloudlocationfinder cloud-locations search \
    --source-cloud-location=CLOUD_REGION \
    --query="cloud_provider=CLOUD_PROVIDER_CLOUD_PROVIDER AND cloud_location_type=CLOUD_LOCATION_TYPE_ZONE" \
    --limit=1

リージョン内のすべての Google Distributed Cloud コネクテッド ゾーンを見つける

このクエリを使用すると、 特定のリージョン内の Distributed Cloud コネクテッド ゾーンを一覧表示できます。

HTTP

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "X-Goog-User-Project: PROJECT 'https://cloudlocationfinder.googleapis.com/v1alpha/projects/PROJECT/locations/global/cloudLocations?filter=containing_cloud_location="projects/PROJECT/locations/global/cloudLocations/CLOUD_REGION%20AND%20cloud_provider=CLOUD_PROVIDER_GCP%20AND%20cloud_location_type=CLOUD_LOCATION_TYPE_GDCC_ZONE"'

gcloud

gcloud cloudlocationfinder cloud-locations list --filter='cloud_provider=CLOUD_PROVIDER_GCP AND cloud_location_type=CLOUD_LOCATION_TYPE_GDCC_ZONE AND containing_cloud_location="projects/PROJECT/locations/global/cloudLocations/CLOUD_REGION"'

特定の地域内のリージョンを見つける

このクエリを使用すると、指定した地域コードを使用して、特定の国または地域または地域の適用法令内のリージョンを特定できます。

HTTP

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "X-Goog-User-Project: PROJECT "https://cloudlocationfinder.googleapis.com/v1alpha/projects/PROJECT/locations/global/cloudLocations:search?source_cloud_location=projects/PROJECT/locations/global/cloudLocations/CLOUD_REGION&query=cloud_provider=CLOUD_PROVIDER_CLOUD_PROVIDER%20AND%20cloud_location_type=CLOUD_LOCATION_TYPE_REGION%20AND%20territory_code=TERRITORY_CODE&page_size=1"

gcloud

gcloud alpha cloudlocationfinder cloud-locations search \
    --source-cloud-location=CLOUD_REGION \
    --filter="cloud_provider=CLOUD_PROVIDER_CLOUD_PROVIDER AND cloud_location_type=CLOUD_LOCATION_TYPE_REGION" AND filter="territory_code=\"TERRITORY_CODE\"" \
    --limit=1

温室効果ガス排出量を最小限に抑えるクラウド ロケーションを一覧表示する

このクエリを使用すると、 リージョンのカーボンフリー エネルギーに基づいて、 Google Cloud 温室効果ガス排出量が最も少ないリージョンを特定できます

HTTP

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "X-Goog-User-Project: PROJECT "https://cloudlocationfinder.googleapis.com/v1alpha/projects/PROJECT/locations/global/cloudLocations?query=cloud_provider=CLOUD_PROVIDER_CLOUD_PROVIDER%20AND%20cloud_location_type=CLOUD_LOCATION_TYPE_REGION&page_size=5"

gcloud

gcloud alpha cloudlocationfinder cloud-locations list \
    --filter="cloud_provider=CLOUD_PROVIDER_CLOUD_PROVIDER AND cloud_location_type=CLOUD_LOCATION_TYPE_REGION" \
    --limit=5

次のステップ