My journey through Google Cloud
— google cloud — 1 min read
This is my exploration into the unchartered territory of Google Cloud, delving into a multitude of tools and services
CLI commands
# to obtain access credentials for the user accountgcloud auth login
# list all available networksgcloud compute networks list --project=:project-name
IDS
https://cloud.google.com/intrusion-detection-system/docs/configuring-ids
Query IDS endpoints across projects
gcloud projects list --format="value(projectId)"
for project_id in $(gcloud projects list --format="value(projectId)"); do echo "Project: $project_id" gcloud ids endpoints list --project=$project_iddone
Query projects that has VPC network but not IDS
# --quiet ignore any interactions
for project_id in $(gcloud projects list --format="value(projectId)"); do # Get IDS Endpoints and VPC Networks for the project ids_endpoints=$(gcloud ids endpoints list --project=$project_id --quiet --format="value(NAME)") vpc_networks=$(gcloud compute networks list --project=$project_id --quiet --format="value(NAME)")
# Check if the project has VPC Networks but doesn't have IDS endpoints if [[ -z "$ids_endpoints" ]] && [[ -n "$vpc_networks" ]]; then echo "Project: $project_id" echo "VPC Networks:" echo "$vpc_networks" echo "-----------------------------" fidone
Pulling a docker image from GCR
24 APR 23
I had to delete a image as it’s not used any more and it has security vulnerabilities. Before deleting it, I wanted to back it up just in case. You have to configure credentials to access GCR.
# logingcloud auth login
# add credentials for GCR repositoriesgcloud auth configure-docker
# pull the imagedocker pull eu.gcr.io/live/gcf/europe-west2/5f4029542275:latest
List compute instances
gcloud compute instances list --project dev-test
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUSeurope-west2-a-gke-bastion europe-west2-a e2-small x.1.0.1 x.100.147.90 RUNNINGgateway-europe-west2-a-8kxt europe-west2-a n1-standard-1 x.0.0.2 x.100.147.10 RUNNINGgreen-europe-west2-a-0h84 europe-west2-a n1-standard-2 x.1.0.3 RUNNINGgateway-europe-west2-b-dwb2 europe-west2-b n1-standard-1 x.0.0.4 x.100.76.10 RUNNINGgreen-europe-west2-b-bzbk europe-west2-b n1-standard-2 x.1.0.5 RUNNINGgreen-europe-west2-c-sz0p europe-west2-c n1-standard-2 x.1.0.6 RUNNING