loading...

Google Cloud Platform – Cloud shell

Docker Compose Tutorial for Beginners

Cloud shell is an interactive shell environment that allows you to manage your GCP resources programmatically, without having to install the Google Cloud SDK. Cloud shell comes readily configured with the gcloud command so you can easily manage your GCP resources. When you click on the cloud shell icon, GCP will deploy a temporary compute engine, g1-small virtual machine, with 5 GB of persistent disk storage. You will also see a command-line access to that instance pop up in the web browser.

These cloud shell virtual machine instances are provisioned per user and on a per-session basis. This instance terminates after one hour of inactivity or when you exit your session. The persistent disk, mounted as a $HOME directory, remains even after the cloud shell instance is destroyed. This $HOME directory is private to you.

Once this instance is fully deployed and initialized, you will see the shell prompt. This instance comes fully configured with the Google Cloud SDK and is able to manage your environment and multiple projects as needed.

Cloud shell also offers a cloud editor which can be used to browse file directories as well as view/edit files. The code editor is another way to enhance your usage of the environment using cloud shell. Other features of cloud shell include a boost mode that temporarily upgrades your cloud shell instance to n1-standard-1 virtual machine. This is handy when you need more CPU and memory to run scripts when needed.

Go to your web console and in the upper right-hand top corner, click on the icon to Activate Cloud Shell:

You will see the bottom of the screen pop up with a connecting status, as shown next. It can take up to 25–40 seconds for the cloud shell to be active, if there isn’t an active session or a cloud shell virtual machine instance. The cloud shell instance is already configured to be used with your GCP account so there is typically no need to run the gcloud init command to initialize. It is also important to remember that you will not be charged for the cloud shell virtual machine and its resources. Cloud shell is free for customers:

You can also click on the pop-out icon if you prefer to use cloud shell in its own web window. On the right-hand side of this frame, click on the Launch code editor BETA icon to start the code editor:

Launching the code editor opens a new window with the editor as shown here:

Cloud shell also comes with the ability to preview your application. Click on the Web preview icon as shown here. This icon is also accessible in the regular cloud shell frame without the need to launch the code editor:

Upon clicking the web preview, you will see the option to pick the port on which your web application can be accessible for preview in the GCP console. The ports need to be within the range of 8080 and 8084. Web preview is great because it only allows you to preview your application behavior in real time without exposing it to the outside world:

Cloud shell is a very powerful tool that can make a developer’s life easy. It also makes it easy to manage your GCP environment without the need to install SDK tools. In fact, even before downloading the SDK toolkit, I spent a considerable amount of time experimenting using cloud shell which made things easy.

Comments are closed.

loading...