Mengelola gateway yang aman

Halaman ini menjelaskan cara menyelesaikan tugas pengelolaan gateway aman umum.

Menyiapkan lingkungan shell

Untuk menyederhanakan proses penyiapan dan berinteraksi dengan API gateway aman, tentukan variabel lingkungan berikut di shell kerja Anda.

  • Parameter umum

    API="beyondcorp.googleapis.com"
    API_VERSION=v1
    PROJECT_ID=MY_PROJECT_ID
    APPLICATION_ID=MY_APPLICATION_ID
    APPLICATION_DISPLAY_NAME="MY_APPLICATION_DISPLAY_NAME"
    HOST_NAME=MY_HOST_NAME

    Ganti kode berikut:

    • MY_PROJECT_ID: ID project tempat gateway aman dibuat.
    • MY_APPLICATION_ID: ID aplikasi Anda, seperti github. Nama dapat berisi hingga 63 karakter, dan dapat berisi huruf kecil, angka, dan tanda hubung. Karakter pertama harus berupa huruf, dan karakter terakhir dapat berupa huruf atau angka.
    • MY_APPLICATION_DISPLAY_NAME: Nama yang dapat dibaca manusia untuk ditampilkan.
    • MY_HOST_NAME: Nama host aplikasi Anda. Contoh, github.com. Panjang nama host maksimal 253 karakter dan harus mengikuti salah satu format berikut:

      • Alamat IPv4 yang valid
      • Alamat IPv6 yang valid
      • Nama DNS yang valid
      • Tanda bintang (*)
      • Tanda bintang (*) diikuti dengan nama DNS yang valid
  • Parameter gateway yang aman

    SECURITY_GATEWAY_ID=MY_SECURITY_GATEWAY_ID
    SECURITY_GATEWAY_DISPLAY_NAME="MY_SECURITY_GATEWAY_DISPLAY_NAME"

    Ganti kode berikut:

    • MY_SECURITY_GATEWAY_ID: ID gateway aman. ID dapat terdiri dari maksimal 63 karakter, dan dapat berisi huruf kecil, angka, dan tanda hubung. Karakter pertama harus berupa huruf, dan karakter terakhir dapat berupa huruf atau angka.
    • MY_SECURITY_GATEWAY_DISPLAY_NAME: Nama gateway aman yang dapat dibaca manusia. Panjang nama maksimal 63 karakter dan hanya boleh berisi karakter yang dapat dicetak.

Memperbarui gateway aman

Contoh berikut menunjukkan cara memperbarui hub gateway aman yang ada.

gcloud

gcloud beta beyondcorp security-gateways update ${SECURITY_GATEWAY_ID} \
  --project=${PROJECT_ID} \
  --location=global \
  --hubs=us-central1,us-east1
      

REST

curl \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
-X PATCH \
-d "{ \"hubs\": {\"us-central1\": {}, \"us-east1\": {}} }" \
"https://${API}/${API_VERSION}/projects/${PROJECT_ID}/locations/global/securityGateways/${SECURITY_GATEWAY_ID}?update_mask=hubs"
      

Mendapatkan detail gateway yang aman

Untuk mendapatkan detail gateway aman, jalankan perintah berikut.

gcloud

gcloud beta beyondcorp security-gateways describe ${SECURITY_GATEWAY_ID} \
  --project=${PROJECT_ID} \
  --location=global
      

REST

curl \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://${API}/${API_VERSION}/projects/${PROJECT_ID}/locations/global/securityGateways/${SECURITY_GATEWAY_ID}"
      

Mencantumkan gateway aman

Untuk mencantumkan semua gateway aman dalam sebuah project, jalankan perintah berikut.

gcloud

gcloud beta beyondcorp security-gateways list \
  --project=${PROJECT_ID} \
  --location=global
      

REST

curl \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://${API}/${API_VERSION}/projects/${PROJECT_ID}/locations/global/securityGateways"
      

Menghapus gateway aman

Untuk menghapus gateway aman, jalankan perintah berikut.

gcloud

gcloud beta beyondcorp security-gateways delete ${SECURITY_GATEWAY_ID} \
  --project=${PROJECT_ID} \
  --location=global
      

REST

curl \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
-X DELETE \
"https://${API}/${API_VERSION}/projects/${PROJECT_ID}/locations/global/securityGateways/${SECURITY_GATEWAY_ID}"
      

Mengupdate resource aplikasi

Contoh berikut menunjukkan cara mengupdate aplikasi yang ada. Kolom yang dapat diedit yang diizinkan mencakup:

  • display_name
  • endpoint_matchers

Anda dapat menggunakan update_mask untuk mengontrol kolom mana yang diperbarui. Contoh berikut menunjukkan cara memperbarui kolom endpoint_matchers:

gcloud

gcloud beta beyondcorp security-gateways applications update ${APPLICATION_ID} \
  --project=${PROJECT_ID} \
  --security-gateway=${SECURITY_GATEWAY_ID} \
  --location=global \
  --endpoint-matchers="hostname=${HOST_NAME}"
      

REST

curl \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
-X PATCH \
-d "{ \"endpoint_matchers\": [{hostname: \"${HOST_NAME}\"}] }" \
"https://${API}/${API_VERSION}/projects/${PROJECT_ID}/locations/global/securityGateways/${SECURITY_GATEWAY_ID}/applications/${APPLICATION_ID}?update_mask=endpoint_matchers"
      

Mendapatkan detail resource aplikasi

Untuk mendapatkan detail aplikasi, jalankan perintah berikut.

gcloud

gcloud beta beyondcorp security-gateways applications describe ${APPLICATION_ID} \
  --project=${PROJECT_ID} \
  --security-gateway=${SECURITY_GATEWAY_ID} \
  --location=global
      

REST

curl \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://${API}/${API_VERSION}/projects/${PROJECT_ID}/locations/global/securityGateways/${SECURITY_GATEWAY_ID}/applications/${APPLICATION_ID}"
      

Mencantumkan resource aplikasi

Untuk mencantumkan semua aplikasi di gateway keamanan, jalankan perintah berikut.

gcloud

gcloud beta beyondcorp security-gateways applications list \
  --project=${PROJECT_ID} \
  --security-gateway=${SECURITY_GATEWAY_ID} \
  --location=global
      

REST

curl \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://${API}/${API_VERSION}/projects/${PROJECT_ID}/locations/global/securityGateways/${SECURITY_GATEWAY_ID}/applications"
      

Menghapus resource aplikasi

Untuk menghapus aplikasi, jalankan perintah berikut.

gcloud

gcloud beta beyondcorp security-gateways applications delete ${APPLICATION_ID} \
  --project=${PROJECT_ID} \
  --security-gateway=${SECURITY_GATEWAY_ID} \
  --location=global
      

REST

curl \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
-X DELETE \
"https://${API}/${API_VERSION}/projects/${PROJECT_ID}/locations/global/securityGateways/${SECURITY_GATEWAY_ID}/applications/${APPLICATION_ID}"