• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

GCP Check Instances Running

January 18, 2020

Here’s how to check if instances are running in GCP.

#!/bin/bash
while IFS=', ' read -r a b c; do
  instance="${a//[[:blank:]]/}"
  project="${b//[[:blank:]]/}"
  zone="${c//[[:blank:]]/}"
  gcloud compute instances describe $instance \
  --zone $zone --project $project \
  --format='table[no-heading](name,status,zone)'
done < instance-list.txt

#!/bin/bash while IFS=', ' read -r a b c; do instance="${a//[[:blank:]]/}" project="${b//[[:blank:]]/}" zone="${c//[[:blank:]]/}" gcloud compute instances describe $instance \ --zone $zone --project $project \ --format='table[no-heading](name,status,zone)' done < instance-list.txt

Instances are read from an external file. File is comma delimited with instance name, project id and zone data.

Filed Under: Cloud Tagged With: check, compute, gcloud, gcp, instances, running, sdk

Search This Website

Subscribe Via Email

  • Home
  • About
  • Archives

Copyright © 2023