Skip to content

Instantly share code, notes, and snippets.

@jackinf
Last active January 31, 2020 10:34
Show Gist options
  • Save jackinf/4c9de26e5aee18cc738e755b56241cc9 to your computer and use it in GitHub Desktop.
Save jackinf/4c9de26e5aee18cc738e755b56241cc9 to your computer and use it in GitHub Desktop.
GCloud commands cheatsheet

GCloud commands

Auth accounts

To re-initialize account

gcloud init

Manage accounts using gcloud auth

gcloud auth list

Functions

Tutorial: https://cloud.google.com/functions/docs/quickstart#functions-prepare-environment-nodejs Sample project: https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git

Deploy

gcloud functions deploy helloGET --runtime nodejs6 --trigger-http

Get url

gcloud functions describe helloGET

Call the function

gcloud functions call helloGET

Buckets

Create a bucket

gsutil mb gs://jrumjantsev-bucket2

Copy image from one bucket to another

gsutil cp image.png gs://jrumjantsev-bucket2

Virtual Machines with subnets

gcloud compute instances create learn-1 --zone=us-east1-b --machine-type=f1-micro --subnet=default
gcloud compute instances create learn-2 --zone=us-east1-b --machine-type=f1-micro --subnet=learnauto
gcloud compute instances create learn-3 --zone=us-east1-b --machine-type=f1-micro --subnet=subnet-1a
gcloud compute instances create learn-4 --zone=us-east1-c --machine-type=f1-micro --subnet=subnet-1b
gcloud compute instances create learn-5 --zone=us-west1-a --machine-type=f1-micro --subnet=subnet-2
gcloud config set project projectId
# login into gcloud
gcloud auth application-default login
# change project
gcloud config set project dev-test-travix-com
# check if the service account is set
echo $env:GOOGLE_APPLICATION_CREDENTIALS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment