Cloud workstations — VS code

Gerardo Lopez Falcón
Google Cloud - Community
5 min readJun 2, 2023

With the increase in remote collaboration over the last three years, development teams have had to find new ways to collaborate, driving increased demand for tools to address the productivity challenges of this new context. This distributed kind of work also adds new security risks, such as information leaving the company’s boundaries. For development teams, this means creating ways to protect the data and source code that serve as intellectual property for many companies.

At Google Cloud Next 22, Google introduced Cloud Workstations, which provides integrated and fully managed development environments on Google Cloud. In other words, Cloud Workstations is a service focused on increasing the productivity of developers’ daily workflows in a secure manner and accelerating developer onboarding.

Of course, the theory always is good but I know that you are looking for examples and comments from people that have been using Cloud Workstations, so let me give you my first impression of creating a Nx project using Cloud Workstations.

Workstation Configuration

First, you don’t have any configuration, you need to do it. It is easy to follow. Pay attention to machine settings because it depends on what kind of experience you will have and how much $$ the workstation will charge.

In Environment settings, use the default option, but you have other editors. that you could befamiliarized.

Create workstation

Use the previous configuration in order to create the workstation

Start it

Launch it

Create a NX project

First, you should check if nx is installed in your workspace:

otherwise, install it

npm install --global nx@latest

Next step, create the nx workspace

yarn create nx-workspace beehive

open the folder project created

Nx has a plugin system that provides functionality for various frameworks. There are official ones and community plugins. One of the official ones is the Nest plugin.

Run the following command to install the plugin:

yarn add -D @nrwl/nest

This plugin provides functionality to create Nest applications and libraries. Let’s start with the application.

nx generate @nrwl/nest:app api

A new NestJs app was created in the root of the nx workspace:

You are ready, you can create an amazing backend app using Nx and NestJS. Ok, but I want to see it running and test it, how?

Connect to a Cloud Workstations host

My experience was amazing, I was able to connect my cloud workstation with my local host (my computer) run the app and test it. Don’t delay.

First, I needed to enable an ssh connection:

It will prompt you a gcloud command that you must run on your local machine. If all is good, on your computer, you must see something similar to the following:

Probably the port is the same but can change, it depends on gcloud cli.

Ok, you already have the ssh connection ready to use, the next step is to go to VS Code. I recommend installing the Remote-SHH plugin in VS code, it will allow you to create connections ssh with VS code.

Once you installed the plugin, launch Remote — SSH, and click Open a Remote Window in the status bar.

Select the Connect to Host option when the command palette opens.

Type user@localhost:PORT , in my case, the port was 57121

If the connection was successful, in the left bottom of the VS code you will be able to see:

Great, you are a rock star. Now, you can run your nx apps locally:

nx serve api

Open your browser and access the endpoint api

Conclusion

  • The experience was amazing, super fast, I didn’t feel any delays while I was coding in my local computer. I felt that my code was in my computer and not connected via ssh.
  • I travel a lot due to my job. So, I didn’t need to use my laptop all time because I was able to develop on my table, PC, and Linux. The reason? The code is stored in Cloud Workstations.
  • The onboarding of my code and dependencies is faster because the new members already have the setup and project ready to use, no more “My computer hasn’t the requirements needed”.

I hope that you enjoyed this reading, I’m waiting for Duet AI extension in Cloud workstations when it is available for the public, I will give you my opinion, in the meantime, thanks for reading it, PURA VIDA.

--

--

Gerardo Lopez Falcón
Google Cloud - Community

Google Developer Expert & Sr Software Engineer & DevOps &. Soccer Fan