Getting started with Google Cloud SDK
Tags: cloud, gcp, devops
Published: 2017-05-04 17:29:06

---
title: Getting started with Google Cloud SDK 
published: true
description: A Simple guide to approach Google Cloud
tags: cloud,GCP, devops
---

Hello, Peeps!

Recently I spoke about Google Cloud SDK in Google Cloud NEXT Extended event at Bangalore. I thought I should write an article about it to give you a fundamental understanding of Google Cloud SDK.


![](https://thepracticaldev.s3.amazonaws.com/i/3wqmf5ohm4jt0k33306u.png)

## **What ?**

Google Cloud SDK is a set of tools for accessing Google public cloud platform in a secure way. It contains essential tools for maintaining, managing and monitoring [Google Cloud Platform (GCP)](https://cloud.google.com/).

It is equivalent of [Amazon Web Services CLI](https://aws.amazon.com/cli/).

## **Why ?**

Essentially many of the enterprises would automate monotonous mundane tasks to manage their infrastructure. Tools like these help in that process.

## **How ?**

### **Installation**

To start working with Cloud SDK, you need to install tools from here depending on your OS platform. One prerequisite is to have Python version 2.7.x or lesser
I recommend you to install the Python bundle coming along with the installer. Because the installer is not compatible with Python version 3.x and above, you can check about the same in [Google Issue tracker](https://issuetracker.google.com/issues?q=cloud%20sdk).

### **Configuring your account**

The first thing to do after successful installation is open your command line and type `gcloud` to check whether Cloud SDK has installed perfectly.
Run `gcloud init`, it opens up a new browser window and asks to login into your google cloud account. Come back to command line and select your options like the project, region/zone etc.

### **Tools and Commands**

Cloud SDK comes along with a set of command tools


*[gcloud](https://cloud.google.com/sdk/gcloud/reference/) : works with Google Compute Engine (equivalent of AWS EC2)*
*[bq](https://cloud.google.com/bigquery/bq-command-line-tool) : works with Cloud Bigquery (can be compared to Amazon Redshift)*
*[gsutil](https://cloud.google.com/storage/docs/gsutil) : works with Cloud Storage (equivalent of AWS S3/AWS EBS)*


You can list/install/update these tools by using below command
    
 `gcloud components list`


![](https://cdn-images-1.medium.com/max/900/1*oqzYDOVVHHGxmxxveXOp4Q.png)

##Scripting using gcloud commands

Use case: Spin up a VM in Cloud Compute engine and run a startup script to copy an image to a Cloud Storage Bucket.

Using gcloud and gsutil commands you can write a Python script. I tried one particular use case by following Google Cloud tutorial. I could not find the same tutorial and I uploaded the code used onto [Github](https://github.com/aravindputrevu/GCloudSDKDemo).

*list-instance.py: will list the instance*
*create-instance.py: creates an instance*
*startup-script.sh: Runs after the VM boots up*

##Cloud API Client Libraries

If you are a programmer and like working with some programming language, Google Cloud has given another way to use GCP.

Google Cloud comes with [7 Client API libraries](http://googlecloudplatform.github.io/google-cloud-java/0.10.0/index.html). You can build a nice dashboard for your AWS and GCP cloud workloads.

There are exhaustive documentation and code samples for API Client Libraries in each language. Here is the [link](https://github.com/GoogleCloudPlatform/google-cloud-java) for Java Samples.

If none of the sample provided has the service implementation for a particular API, you can write your own implementation by using Google APIs

##Security and Privacy Considerations

Last but not the least, Using Google Cloud SDK on your local machine might create some doubts to you in the security perspective. `gsutil` ensures all the data transferred via TLS protocol to prevent any data leakage.

There are a ton of measures taken to ensure security while running these commands in your local/dev machine. However, in [this](https://cloud.google.com/storage/docs/gsutil/addlhelp/SecurityandPrivacyConsiderations) article GCP explains would handle security risks.

If you are still not satisfied, without installing any command line tool, you can open a Cloud Dev Shell via [GCP Console](https://console.cloud.google.com/).

![](https://cdn-images-1.medium.com/max/900/1*HdNhAOFqO1T6BeCSyPBklg.png)

I hope I gave a primer of the Cloud SDK. But if you still need more details then head over to this [link](https://cloud.google.com/sdk/docs/) OR drop a comment.

Thank you !