GCP Start Multiple Instances
Here’s how to start multiple instances using Bash and Google SDK.
<pre lang="bash">
#!/bin/bash
while IFS=', ' read -r a b c; do
instance="${a//[[:blank:]]/}"
project="${b//[[:blank:]]/}"
zone="${c//[[:blank:]]/}"
echo "Starting $instance ...."
gcloud compute instances start $instance \
--zone $zone --project $project --async
done
<p>Instances are read from an external file. The file format is displayed below.</p>
<pre lang="bash">server1,project1,us-central1-a
server2,project2,us-central1-b
server3,project3,us-central1-c
<p>To stop multiple instances, replace "start" with "stop."</p>