Skip to content

Instantly share code, notes, and snippets.

@switchspan
Created December 9, 2021 19:32
Show Gist options
  • Save switchspan/84eca2aecef7405186617001d844e756 to your computer and use it in GitHub Desktop.
Save switchspan/84eca2aecef7405186617001d844e756 to your computer and use it in GitHub Desktop.
Gcloud CLI Commands

GCloud CLI commands

Credentials

List all of the current logins

gcloud auth list

Change the active account

gcloud config set account <account email>

Configuration

List the current configuration

gcloud config list

Change the current project

gcloud config set project <project id>

Info

Displays all of the current configuration and info about the Gcloud CLI

gcloud info

AppEngine Deploy

Deploy application using default app.yaml file to GAE

gcloud app deploy app.yaml

Cloud Functions

Deploying a function

Cloud functions can be deployed on nodejs 8 or 10.

Deploy cloud function (http trigger):

gcloud function deploy 'testfunc' --runtime nodejs8 \ --trigger-http --entry-point=myFunction

Deploy cloud function (event trigger):

gcloud functions deploy helloPubSub --runtime nodejs10 \ --trigger-topic YOUR_TOPIC_NAME

Listing event types

List available cloud function event types:

gcloud functions event-types list

Viewing logs

gcloud functions logs read --limit 50

Cloud Pub/Sub

Creating a Topic

gcloud pubsub topics create YOUR_TOPIC_NAME

Publishing a message to a topic

gcloud pubsub topics publish YOUR_TOPIC_NAME --message YOUR_MESSAGE

Cloud Tasks

Creating a Task Queue

gcloud tasks queues create [QUEUE_ID]

Describe a Task Queue

gcloud tasks queues describe [QUEUE_ID]

View all Task queues

gcloud tasks queues list

Turning on logging

gcloud tasks queues create [QUEUE_ID] --log-sampling-ratio=1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment