Cette page explique comment effectuer des tâches courantes de gestion des passerelles sécurisées.
Configurer votre environnement shell
Pour simplifier le processus de configuration et interagir avec les API de la passerelle sécurisée, définissez les variables d'environnement suivantes dans votre shell de travail.
Paramètres généraux
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
Remplacez les éléments suivants :
MY_PROJECT_ID
: ID du projet dans lequel la passerelle sécurisée est créée.MY_APPLICATION_ID
: ID de votre application, tel quegithub
. Le nom peut comporter jusqu'à 63 caractères (lettres minuscules, chiffres et tirets). Le premier caractère doit être une lettre, et le dernier peut être une lettre ou un chiffre.MY_APPLICATION_DISPLAY_NAME
: nom lisible à afficher.MY_HOST_NAME
: nom d'hôte de votre application. Exemple :github.com
. Le nom d'hôte peut comporter jusqu'à 253 caractères et doit respecter l'un des formats suivants :- Une adresse IPv4 valide
- Une adresse IPv6 valide
- Un nom DNS valide
- Un astérisque (*)
- Un astérisque (*) suivi d'un nom DNS valide
Paramètres de la passerelle sécurisée
SECURITY_GATEWAY_ID=
MY_SECURITY_GATEWAY_ID
SECURITY_GATEWAY_DISPLAY_NAME="MY_SECURITY_GATEWAY_DISPLAY_NAME
"Remplacez les éléments suivants :
MY_SECURITY_GATEWAY_ID
: ID de la passerelle sécurisée. L'ID peut comporter jusqu'à 63 caractères et contenir des lettres minuscules, des chiffres et des traits d'union. Le premier caractère doit être une lettre, et le dernier peut être une lettre ou un chiffre.MY_SECURITY_GATEWAY_DISPLAY_NAME
: nom lisible de la passerelle sécurisée. Le nom peut comporter jusqu'à 63 caractères et ne peut contenir que des caractères imprimables.
Mettre à jour une passerelle sécurisée
L'exemple suivant montre comment mettre à jour les hubs d'une passerelle sécurisée existante.
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"
Obtenir les détails d'une passerelle sécurisée
Pour obtenir les détails d'une passerelle sécurisée, exécutez la commande suivante.
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}"
Lister les passerelles sécurisées
Pour lister toutes les passerelles sécurisées d'un projet, exécutez la commande suivante.
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"
Supprimer une passerelle sécurisée
Pour supprimer une passerelle sécurisée, exécutez la commande suivante.
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}"
Mettre à jour une ressource d'application
L'exemple suivant montre comment mettre à jour une application existante. Voici les champs modifiables autorisés :
display_name
endpoint_matchers
Vous pouvez utiliser update_mask
pour contrôler les champs mis à jour.
L'exemple suivant montre comment mettre à jour le champ 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"
Obtenir les détails d'une ressource d'application
Pour obtenir les détails d'une application, exécutez la commande suivante.
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}"
Lister les ressources d'application
Pour lister toutes les applications d'une passerelle de sécurité, exécutez la commande suivante.
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"
Supprimer une ressource d'application
Pour supprimer une application, exécutez la commande suivante.
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}"