Useful Google Cloud Shell Commands

Here are some of the most useful commands I have picked up with my time on Google Cloud Shell. This list is not definitive, but I am sure that you will get some use from them.

How to prevent project deletion in Google Cloud Shell

This is a great command to protect your cloud projects from over zealous system administrators. This is ideal for a production environment.

gcloud beta resource-manager org-policies enable-enforce \     --organization $ORG_ID compute.restrictXpnProjectLienRemoval

How to enable service APIs in Google Cloud Shell

Service APIs are disabled by default. Therefore, the first time your log into Google Cloud, the majority of APIs will need to be enabled and associated to your project:

gcloud services enable container.googleapis.com
gcloud services enable containerregistry.googleapis.com
gcloud services enable cloudbuild.googleapis.com
gcloud services enable iam.googleapis.com
gcloud services enable logging.googleapis.com
gcloud services enable monitoring.googleapis.com
gcloud services enable storage-api.googleapis.com
gcloud services enable storage-component.googleapis.com
gcloud services enable sourcerepo.googleapis.com

How to check the configuration of your project in Google Cloud Shell

# Check default project setting

 gcloud config get-value project 

# Set default project (change myproject value)

 gcloud config set project <em>myproject </em>

How to create a networking firewall rule to open a port in Google Cloud Shell

One of the many tasks you will need to do as a Cloud Administrator is to open firewall port. The Cloud Shell makes this process dead easy, here is how to create a firewall rule to open up the 8000 port range

 gcloud compute firewall-rules create open-range-8000 \  --action allow \  --direction ingress \  --rules tcp:8000-9000 \  --source-ranges 0.0.0.0/0 \  --priority 1000 \  --target-tags open-range-8000 

How to list available production compute resources for Deployment Manager in Google Cloud Shell

 gcloud deployment-manager types list | grep v1.*instance 

Example:

gcloud deployment-manager types list | grep v1.*instance spanner.v1.instance compute.v1.instanceGroupManager sqladmin.v1beta4.instance compute.v1.instanceGroup compute.v1.instanceTemplatecompute.v1.instance
Elsewhere On TurboGeek:  Auto-Scaling in GCP

Richard.Bailey

Richard Bailey, a seasoned tech enthusiast, combines a passion for innovation with a knack for simplifying complex concepts. With over a decade in the industry, he's pioneered transformative solutions, blending creativity with technical prowess. An avid writer, Richard's articles resonate with readers, offering insightful perspectives that bridge the gap between technology and everyday life. His commitment to excellence and tireless pursuit of knowledge continues to inspire and shape the tech landscape.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate ยป