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 menginisialisasi 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.

Menjelajahi kueri umum Cloud Location Finder

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 zona Google Cloud terdekat dengan lokasi cloud menggunakan data kedekatan untuk penyedia cloud yang Anda tentukan.

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

Menemukan semua zona Google Distributed Cloud terhubung dalam suatu region

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

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

Menemukan wilayah dalam area tertentu

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

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

Mencantumkan lokasi cloud yang meminimalkan jejak karbon

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

Langkah berikutnya