gcloud

19th February 2018 at 11:18pm
GCE GCP TechnicalNotes
# General
gcloud projects list
gcloud config set compute/zone europe-west4-b

# Google Compute Engine
gcloud compute images list
gcloud compute zones list
gcloud machine-types list # f1-micro is the smallest burstable size

latest_image () {
  gcloud compute images list --sort-by ~NAME --format json --filter "$1" \
    | jq -r '.[0].name'
}

gcloud compute instances create $INSTANCE_NAME \
  --image "$(latest_image cos-stable)" \
  --image-project cos-cloud \
  --zone europe-west4-b \
  --machine-type f1-micro \
  --tags http-server,https-server \
  --metadata-from-file user-data=cloud-config.yaml
    
gcloud compute ssh $INSTANCE_NAME \
  --project $PROJECT_ID \
  --zone $ZONE

Related