Panduan memulai: Mengaktifkan Cloud Location Finder dan menjalankan kueri

Halaman ini menunjukkan cara mengaktifkan Cloud Location Finder menggunakan Google Cloud CLI dan menemukan lokasi cloud berdasarkan kedekatan, yurisdiksi, dan jejak karbon. Anda dapat menemukan lokasi menggunakan permintaan HTTP atau perintah Google Cloud CLI.

Sebelum memulai

  1. Instal Google Cloud CLI.
  2. Untuk melakukan inisialisasi Google Cloud CLI, jalankan perintah berikut:
    gcloud init
    
  3. Aktifkan Cloud Location Finder API:
    gcloud services enable cloudlocationfinder.googleapis.com  --project PROJECT
    
  4. Tambahkan peran cloudlocationfinder.viewer:
    gcloud projects add-iam-policy-binding PROJECT \
        --member USER_IDENTIFIER \
        --role roles/cloudlocationfinder.viewer
    
    • Ganti PROJECT dengan project ID Anda.
    • Ganti USER_IDENTIFIER dengan ID untuk akun pengguna Anda. Misalnya, user:myemail@example.com.
  5. Jika Anda berencana menemukan lokasi Google Distributed Cloud terhubung menggunakan Cloud Location Finder, aktifkan GDC Hardware Management API dan tambahkan peran gdchardwaremanagement.reader:
    gcloud projects add-iam-policy-binding PROJECT \
        --member USER_IDENTIFIER \
        --role roles/gdchardwaremanagement.reader
    

Menjelajahi kueri Cloud Location Finder umum

Cloud Location Finder memungkinkan Anda membuat kueri repositori lokasi cloud untuk mengidentifikasi lokasi cloud terdekat berdasarkan kedekatan, kode wilayah, atau konsumsi energi bebas karbon (CFE%) Google. Bagian berikut memberikan contoh umum cara berinteraksi dengan repositori Cloud Location Finder.

Cloud Location Finder menggunakan sintaksis gRPC Transcoding.

  • Ganti PROJECT dengan project ID Anda.
  • Ganti CLOUD_REGION dengan region cloud sumber untuk menemukan lokasi terdekat, termasuk awalan penyedia cloud. Misalnya, gcp-us-central1 atau aws-us-east-1.
  • Ganti CLOUD_PROVIDER dengan penyedia cloud untuk menemukan lokasi terdekat. Misalnya, AWS atau GCP.

Menemukan zona cloud terdekat

Gunakan kueri ini untuk mengidentifikasi nearest Google Cloud zone ke lokasi cloud menggunakan data kedekatan untuk penyedia cloud yang Anda tentukan.

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

Menemukan semua zona Google Distributed Cloud terhubung di suatu region

Gunakan kueri ini untuk mencantumkan zona Distributed Cloud terhubung dalam region tertentu.

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"'

Menemukan region dalam wilayah tertentu

Gunakan kueri ini untuk mengidentifikasi region dalam wilayah atau yurisdiksi tertentu, menggunakan kode wilayah yang Anda berikan.

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

Mencantumkan lokasi cloud yang meminimalkan jejak karbon

Gunakan kueri ini untuk mengidentifikasi region dengan jejak karbon terendah berdasarkan Energi bebas karbon untuk Google 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?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

Langkah berikutnya