クイックスタート: Cloud Location Finder を有効にしてクエリを実行する
このページでは、Google Cloud CLI を使用して Cloud Location Finder を有効にし、近接性、管轄区域、カーボン フットプリントに基づいてクラウド ロケーションを検索する方法について説明します。ロケーションは、HTTP リクエストまたは Google Cloud CLI コマンドを使用して検索できます。
始める前に
- Google Cloud CLI をインストールします。
- Google Cloud CLI を初期化するには、次のコマンドを実行します。
gcloud init
- Cloud Location Finder API を有効にします。
gcloud services enable cloudlocationfinder.googleapis.com --project PROJECT
cloudlocationfinder.viewerロールを追加します。gcloud projects add-iam-policy-binding PROJECT \ --member USER_IDENTIFIER \ --role roles/cloudlocationfinder.viewer- PROJECT は、実際のプロジェクト ID に置き換えます。
- USER_IDENTIFIER は、ユーザー アカウントの ID に置き換えます。例: user:myemail@example.com。
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)" "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)" '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)" "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 list \
--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)" "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
次のステップ
- サポートされているロケーションを確認する
- 位置情報検索クエリの構文について
- API リファレンスを確認する